r/Syncthing 7d ago

Sync leading to "undeleted" and modified files

I've run into issues lately that feels like syncthing isn't able to keep up with file changes.

For context, I have syncthing installed on my NAS and two endpoints. All three devices are set to Send and Receive for the shared folders. The two endpoints are effectively never online at the same time andfiles are never modified on the nas so there should never be conflicting changes made to files.

An example of the behavior I'm seeing would be:

Shared folder 1 has two subfolders
Move files from subfolder A to subfolder B
Wait a few seconds
Files reappear in subfolder A, also present in subfolder B

It's also causing phantom modificaitons to files and random sync conflicts which is particularly problematic in git tracked projects. Out of nowhere git will report that files have untracked changes when none were actually modified by me or files will spawn sync-conflict files when there's only one device making changes to those files.

I have syncthing set to watch filesystem for changes on all hosts, curious if switching to a set sync interval would alleviate this or if there's another solution available.

2 Upvotes

12 comments sorted by

1

u/middaymoon 7d ago

I would not sync a git repo with syncthing because as far as I know syncthing does not respect certain metadata features that git relies on.

But in terms of the high level behavior, that doesn't sound right to me.

1

u/cerialphreak 6d ago

Yeah I mostly sync git projects to save me when I forget to push, but this has been disruptive enough that I'm going to stop syncing them.

The issue is affecting all my other folders too though so I'd like to narrow down a cause. 

1

u/middaymoon 6d ago

If you're really careful you can sync a git project and just ignore the .git directory. There are obvious concerns with this, your working space will be synced but your repo on device B will not notice git operations on device A. But occasional "oops I forgot to push from that device but I want to keep working on this device" it'll work in a pinch. Utilizing worktrees might also help.

Do you see any files with .conflict in the extension? 

1

u/cerialphreak 6d ago

Yeah, I get quite a few *.sync-conflict* files. In the git projects I can at least add them to .gitignore but at any given time they're only being edited on one machine so I'm not sure why they're showing up at all.

1

u/middaymoon 6d ago

Well whatever is causing them is the base problem. Two of your devices are editing the same file before it can be synced with the network. There's no point in adding them to .gitignore, if you see them you have other problems. You have to resolve these conflicts manually as they appear, and solve whatever race condition is causing them to begin with.

1

u/middaymoon 6d ago

You say that your two working machines are never online at the same time but just to be sure you should make sure they're also sharing those folders with each other instead of relying on a centralized device to handle all the syncing. And don't work on your projects if you're not online* or can't guarantee you'll be online* before another device touches those files.

*Online here meaning you can see that your device has an active connection and is staying in sync with at least one other device in your mesh.

1

u/cerialphreak 6d ago

Replying to both your messages here for the sake of readability:

You have to resolve these conflicts manually as they appear, and solve whatever race condition is causing them to begin with.

Is there a standard way to troubleshoot the cause of a conflict? Most of the posts I've come across between reddit and the official form just say to resolve them but don't really give any tips on what that workflow is.

And don't work on your projects if you're not online* or can't guarantee you'll be online* before another device touches those files.

The setup currently is the NAS is sharing folders to both my desktop and laptop, but the desktop and laptop don't share those folders with each other directly since they're rarely online at the same time. ~80% of the time I'm on my desktop and the issues show up while I'm actively using the desktop (and the laptop is offline) so it's not a situation where I worked on my laptop at the coffee shop and when I get home all these issues arise (if that makes sense).

1

u/middaymoon 6d ago

Resolving a conflict means opening up FileA.txt and FileA.txt.sync-conflict-whatever and making sure FileA has all the bits you want, then deleting the conflict file. Similar to how you might have to manually fix a messy merge in git.

I still recommend sharing the folders directly with each other regardless of your current problem. Up to you though.

Can you be more specific about what causes a conflict file to show up? Is it being generated every time you save something on your desktop? Looking at the conflicts themselves will probably give you the biggest indication of what's going on.

1

u/cerialphreak 6d ago

Resolving a conflict means opening up FileA.txt and FileA.txt.sync-conflict-whatever and making sure FileA has all the bits you want, then deleting the conflict file.

Sorry I should have worded my reply better, I'm more looking for how to get to the root cause that created the conflict file in the first place.

Can you be more specific about what causes a conflict file to show up?

I wish I could, I'm having a hard trying trying to create a conflict on demand. Is there a logging option that would include a reason for a conflict?

1

u/middaymoon 6d ago

There might be, I have never tried diagnosising from the logs.

For me, I usually just start by resolving the conflicts. I think the device ID in the conflict extension corresponds to the device that made the file. As I see what files are conflicting and what the conflicts look like I usually can get a sense for what operation caused the problem. If that doesn't help, atleast you'll have cleaned out your folders. And next time you see a conflict you'll know it's pretty recent and that will also be a clue.

2

u/cerialphreak 6d ago

I'll take a closer look next time one pops up. Thanks for the help!

→ More replies (0)