You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Removing and re-adding a folder may cause data loss #3876
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Removing and re-adding a folder causes a reset of the index for that folder and a rescan. Consider the following scenario, with two devices A and B:
A and B are in sync
A and B are disconnected
A changes a couple of files, version vector gets bumped, let's say {A:42, B:36}
A removes and re-adds the folder
A rescans and assigns new version vectors with {A:1} to everything
A and B connect
B's older file will have a version vector like {A:40, B: 36}
B's older files overwrite A's newer files (it's not a conflict)
Maybe not a super common scenario, but a folder can be removed by mistake and re-added, or because it's moved on disk, or for many other reasons.
Idea: should the short ID in the version vector not be based on our device ID, but instead a random ID assigned to the folder, e.g., our delta index ID?
I was about to submit a bug report about this, then read this issue. I ran into this very thing except in my case, I was moving files on "A", then the disk holding "B" failed (the syncthing config on both hosts was still intact.) So, I removed the folder on B's syncthing and readded it (B now contained partial contents restored), and the results can only be described as pandemonium... after an initial bit of resyncing, moving a file on B would sometimes result in the file instantly being deleted or moved to "sync-conflict", presumably because A's history last saw that file in that state. Thinking about it, it is hard to figure out what exactly should happen in cases like this, but "WTF" behavior is probably not the best. Even a workaround that would give you a warning at some point (maybe at the point there is a suspect folder added) would be preferable.
What about just changing the version vector from:
current ) monotonically increasing from one
proposed ) unix timestamp based on when it was modified (always increasing as well but later time will never be less than anything done in past even if client is reset or forgets its config)
Or is this one of those things that "fixes something only to break a bunch of other things". I'm guessing that's the case since no ones has mentioned such a simple solution.
Looking at this again I don't understand why I shot down nrm21's suggestion. It sounds totally reasonable and I had the same thought now. If the clocks are wrong there will be no gain, which is the same situation as now -- currently we're effectively using this method but with clocks that are always stuck at zero. Using newV = max(oldV+1, currentTime) handles this correctly in the common case that clocks are mostly right.
bugA problem with current functionality, as opposed to missing functionality (enhancement)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussion
Activity
blindchimp commentedon Feb 16, 2017
I was about to submit a bug report about this, then read this issue. I ran into this very thing except in my case, I was moving files on "A", then the disk holding "B" failed (the syncthing config on both hosts was still intact.) So, I removed the folder on B's syncthing and readded it (B now contained partial contents restored), and the results can only be described as pandemonium... after an initial bit of resyncing, moving a file on B would sometimes result in the file instantly being deleted or moved to "sync-conflict", presumably because A's history last saw that file in that state. Thinking about it, it is hard to figure out what exactly should happen in cases like this, but "WTF" behavior is probably not the best. Even a workaround that would give you a warning at some point (maybe at the point there is a suspect folder added) would be preferable.
nrm21 commentedon May 9, 2017
What about just changing the version vector from:
current ) monotonically increasing from one
proposed ) unix timestamp based on when it was modified (always increasing as well but later time will never be less than anything done in past even if client is reset or forgets its config)
Or is this one of those things that "fixes something only to break a bunch of other things". I'm guessing that's the case since no ones has mentioned such a simple solution.
calmh commentedon May 9, 2017
calmh commentedon May 5, 2020
Looking at this again I don't understand why I shot down nrm21's suggestion. It sounds totally reasonable and I had the same thought now. If the clocks are wrong there will be no gain, which is the same situation as now -- currently we're effectively using this method but with clocks that are always stuck at zero. Using
newV = max(oldV+1, currentTime)handles this correctly in the common case that clocks are mostly right.AudriusButkevicius commentedon May 5, 2020
I guess in the case of merging the vectors you'd always end up with a conflict, because you would always be concurrent newer?
lib/protocol: Avoid data loss on database wipe by higher version numb…
calmh commentedon May 5, 2020
Yeah, that's the intention. There is no shared history, so it must become a conflict. Then our conflict resolution does the right thing.
lib/protocol: Avoid data loss on database wipe by higher version numb…
AudriusButkevicius commentedon May 5, 2020
Does it? I think it used to, but now I think it creates conflict files unconditionally, even if they are the same?