Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destination files sometimes owned by root #5

Open
ari opened this issue Apr 13, 2018 · 15 comments
Open

Destination files sometimes owned by root #5

ari opened this issue Apr 13, 2018 · 15 comments

Comments

@ari
Copy link
Contributor

ari commented Apr 13, 2018

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.

@kruggs
Copy link

kruggs commented May 2, 2018

@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

@ari
Copy link
Contributor Author

ari commented May 3, 2018

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.

@blood-ik
Copy link

blood-ik commented Jan 9, 2020

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

@ari
Copy link
Contributor Author

ari commented Jan 9, 2020

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

@ROBERT-MCDOWELL
Copy link

just add an exec in action{} like chown xxx

@lge
Copy link
Contributor

lge commented Sep 18, 2020

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?

@alexanderheckel
Copy link

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?

@lge
Copy link
Contributor

lge commented Sep 27, 2020 via email

@ROBERT-MCDOWELL
Copy link

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

@erlandl4g
Copy link

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.

@lge
Copy link
Contributor

lge commented Jul 29, 2021 via email

@erlandl4g
Copy link

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

@erlandl4g
Copy link

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.

@erlandl4g
Copy link

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.

@erlandl4g
Copy link

erlandl4g commented Sep 15, 2021

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
Projects
None yet
Development

No branches or pull requests

7 participants