Skip to content

Destination files sometimes owned by root #5

Open

Description

@ari

There is a condition which causes files in the destination server to be owned by root instead of the correct user. It has been discussed on the mailing list and one hypothesis is here:

http://lists.linbit.com/pipermail/csync2/2017-September/000080.html

This is a pretty serious bug for us since we run a WebDAV server cluster with csync2 and lots of small file operations to servers across the cluster at the same time.

Activity

  1. kruggs commented on May 2, 2018

    @kruggs

    @ari i discover this issue this morning. Files got a wrong uid (not the same between each node).
    This might help you : http://sys.ldvi.fr/csync2.html
    It's for v1.34 but you can easily edit daemon.c and update.c without patching, to have your csync2 works with user/group strings. So far it's "working" for me. Be careful I didn't test all case !
    Hope it will help.

    Thanks

  2. ari commented on May 3, 2018

    @ari
    ContributorAuthor

    Thanks for this. In my case I'm pretty sure all the user/group ids and string names match each other across all machines. So I don't think it is the same problem. At any rate, its completely random and happens maybe only one in every 10,000 file operations.

  3. blood-ik commented on Jan 9, 2020

    @blood-ik

    @ari , I have the same problem, did you find any solution for it?

  4. ari commented on Jan 9, 2020

    @ari
    ContributorAuthor

    No, I moved to other solutions with plain rsync on multiple masters which proved simpler for my use-case.

  5. ROBERT-MCDOWELL commented on Jan 9, 2020

    @ROBERT-MCDOWELL

    just add an exec in action{} like chown xxx

  6. lge commented on Sep 18, 2020

    @lge
    Contributor

    This should have become better with c856e93

    but it should actually be implemented as "send all the context information first, then (try to) apply the changes in one go" by preparing the new file with proper content and ownership and permissions and acls and mtimes and so on first, before materializing it into place.

    Any volunteers?

  7. alexanderheckel commented on Sep 26, 2020

    @alexanderheckel

    Feedback: compiled/installed 83b3644 yesterday but found some synchronized files owned as root (= should be www-data) this morning :(. Could one explain the race condition for this behaviour?

  8. lge commented on Sep 27, 2020

    @lge
    Contributor
  9. ROBERT-MCDOWELL commented on Sep 27, 2020

    @ROBERT-MCDOWELL

    an idea, why not to compress/archive the file keeping the permissions and owner intact then transfer decompressed on the fly?

  10. erlandl4g commented on Jul 29, 2021

    @erlandl4g

    I have started sponsoring the fix with transfers sometimes getting root.root 600 ownership/permissions. The fix attempted on previous commits was not doing the job and I have created a list of TODO based on suggestions I have read from a number of people.

    It is currently in testing phase where files are transferred to TMP folder first with a unique name, permissions and ownership applied and then file MOVED into final destination folder.

    There are still some issues with newly created files and this bug is being looked into too.

    Hostname detection was also a problem when a host has several names and this has been fixed and tested (otherwise it required to use -N hostname switch when cluster hostnames did not match main hostnames).

    It may take a week or two more to polish these fixes before we start implementing multithreading (to send file changes to all hosts at the same time and not one host at a time which is slow when there are many hosts with many files to sync).

    Preview of work done can be seen at https://github.com/Shotaos/csync2

    Please keep all suggestions and comments on LINBIT project (not on Shota) as all code improvements will the published on LINBIT git once I see satisfactory results for permissions, ownership, hostname and multithreading (which will be tested on 4 node setup with 100k files each) for everyone to test and improve.

  11. lge commented on Jul 29, 2021

    @lge
    Contributor
  12. erlandl4g commented on Jul 29, 2021

    @erlandl4g

    Thank you, will take your notes into consideration when making changes. Would you be able to share the uncommitted files you have mentioned?

  13. erlandl4g commented on Aug 31, 2021

    @erlandl4g

    Have some improvements made:

    Add hostname guessing feature in simple mode
    Add atomicpatch command to the protocol (-a switch)
    Add -a flag to activate atomicpatch
    Fix missing commas in struct
    Fix command argument printing to only include existent arguments
    Fix bug in command argument printing to check for empty, not NULL, string
    Add conformance to gnu90 std
    Fix the timestamp bug
    Hide debug logging behind -O flag

    Was testing for a while and in a 4 node setup it transfers files correctly with correct timestamp and ownership,

    There are 7 files changed but have no write permissions. Could push commit for review and wider testing.

  14. erlandl4g commented on Sep 1, 2021

    @erlandl4g

    Current work is on making Csync2 multithreaded. That is - to send files to all nodes at once, not one by one. Currently it takes 5 seconds on 1 node sending. So 4 nodes take 20-30 seconds. And it grows with number of nodes.

    It was not designed to work in thread safe way and that is a challenge to change that.

  15. erlandl4g commented on Sep 15, 2021

    @erlandl4g

    Completely fixed ownership and timestamp problem. The only minor thing missing - directory mtime preservation. Will make it in the next fixes. Will leave multithreading for now as that requires database change. Will work on making csync2 faster with file scans, less connections and actually do the work very quickly without going with multithreading. Made a PULL REQUEST for latest changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions