syncthing-android icon indicating copy to clipboard operation
syncthing-android copied to clipboard

Data loss: discarding conflicts

Open dkaparis opened this issue 7 years ago • 22 comments

Syncthing android seems to discard its own changes when a conflicting change with a later timestamp comes from another system. I'm testing with Syncthing Android on my phone and Syncthing on a linux PC.

To reproduce

  1. Create a test file on one device, which gets synced to both.
  2. Disconnect one device from network, or pause syncing
  3. Make conflicting modifications on both devices.
  4. Re-establish connection and syncing
  5. If the modification on the android device in step 3 was later than the PC, a .conflict file will be correctly created; however if the file on the android device was modified first, it will get updated with the conflicting modification from PC, losing the changes on android.

Version Information

App Version: 0.10.4
Syncthing Version: v0.14.43
Android Version: Android 7.1.2 / LineageOS 14.1 / Motorola Moto G 2014

PC Syncthing Version: v0.14.44, Linux (64 bit)

dkaparis avatar Feb 13 '18 20:02 dkaparis

I tried to reproduce this with the exact same version information (except that device is Samsung Galaxy S5) but in both cases (first modification on Android/PC) I get a conflict file with the content from the file modified earlier (and the conflict file appears on both devices).

felixwiemuth avatar Mar 08 '18 13:03 felixwiemuth

I just tried with another device (Motorola Moto G5S Plus, with stock android; also updated PC Syncthing to 0.14.45) and consistently reproduce the same behavior (conflicting modifications from android device are discarded when done earlier).

Going through log files, the only relevant entry I can locate is in the android log, after connection entry (test.txt is the file I'm modifying on both sides):

03-09 15:34:46.068 I/EventProcessor( 6787): Rescanned file via MediaScanner: /storage/emulated/0/Android/data/com.nutomic.syncthingandroid/files/default/test.txt

Version Information

App Version: 0.10.4
Syncthing Version: v0.14.43
Android Version: Android 7.1.1 / Stock Motorola Moto G5S Plus

PC Syncthing Version: v0.14.45, Linux (64 bit)

dkaparis avatar Mar 09 '18 13:03 dkaparis

@dkaparis Can you still reproduce this issue with the current version 0.10.8 available on play store? If that does not help, you can export your config in the apps menu and try a debug build importing the config. Link [removed] Please backup your data first, as the debug build may contain bugs as it is based on a release candidate (0.14.47rc3+commit).

Catfriend1 avatar Apr 22 '18 12:04 Catfriend1

Yes, I still reproduce it with 0.10.8 on the phone and 0.14.46 on PC. I'll try the release candidate and report back when I get around to it.

dkaparis avatar Apr 24 '18 19:04 dkaparis

I am pretty sure the RC or whatever won't help here as there hasn't been any changes in that department, yet someone else needs to validate the reproducer.

Nothing hits my head as to why this happens, as the implementation is the same across platforms.

AudriusButkevicius avatar Apr 24 '18 19:04 AudriusButkevicius

@dkaparis In which paths are the folders configured you are syncing? I mean it like this:

  1. PC - Windows machine with NTFS USB thumb drive - E:\mysync
  2. Android - /storage/emulated/0/my-folder

Catfriend1 avatar Apr 27 '18 23:04 Catfriend1

I tested with two different PC configurations, with identical results:

  1. Debian machine, v0.14.41, ext4 filesystem, directory path /home/syncthing/Sync
  2. Arch-linux machine, v0.14.46, ext4 filesystem under LUKS encrypted volume

Android configuration: Internal storage (no SD card), path: /storage/emulated/0/Android/data/com.nutomic.syncthingandroid/files/default/

dkaparis avatar May 03 '18 11:05 dkaparis

@dkaparis Thanks for the details. Does it help setting ignore permissions on the linux partners?

Catfriend1 avatar May 03 '18 11:05 Catfriend1

Just tested with "Ignore Permissions" checked for the folder on PC - same behavior.

dkaparis avatar May 04 '18 14:05 dkaparis

You reproduced with 2 pcs and no android involved?

AudriusButkevicius avatar May 04 '18 17:05 AudriusButkevicius

No, with 2 PCs conflict files are always created properly.

dkaparis avatar May 05 '18 09:05 dkaparis

I'm having this issue with two PCs, specifically when I just save a file without changing it. I have a text file with my todos in it, if I open the app I'm using to edit it on my desktop while my laptop is off, it'll autosave the text file, which overwrites all the changes I made that day while disconnected from my home network.

My laptop is running: v0.14.49, Linux (64 bit) on Arch Linux My desktop is running: v0.14.49, Linux (64 bit) on Ubuntu 17.10

Could it be that the file name is 1533676510.sync-conflict-20180823-021915-NJNTDTX.m!note because I started writing in a sync conflict version a while back?

CheesecakeCG avatar Aug 30 '18 22:08 CheesecakeCG

Saving a file without changing it still counts as a change.

AudriusButkevicius avatar Aug 31 '18 07:08 AudriusButkevicius

Yeah, this issue is that it's overwriting the older version of a file instead of making a sync conflict. That's what's happening here.

CheesecakeCG avatar Sep 02 '18 15:09 CheesecakeCG

If the only difference is the modification time then it makes sense?

AudriusButkevicius avatar Sep 02 '18 16:09 AudriusButkevicius

Essentially what I am trying to say is that auto-save will bump the version of the file, which is enough to cause a conflict with some device which modified the file offline. Yet just autosaving with the same content between two devices even if one is offline I don't think causes conflicts, as content is the same.

AudriusButkevicius avatar Sep 02 '18 18:09 AudriusButkevicius

Ah, I understand now, that could definitely be a cause. Now I wish I knew Go so I could go and fix this.

CheesecakeCG avatar Sep 04 '18 21:09 CheesecakeCG

It's intended to work this way, so there is nothing to fix.

AudriusButkevicius avatar Sep 05 '18 07:09 AudriusButkevicius

Hi.

Same problem here, but inverse behavior. The problem is like what @dkaparis said in first post of this page, but the difference is:

If the modification on the android device was later than the PC, no conflict file created and PC changes will be loss. But when PC changes is later than android, conflict file will created. It's inverse of what @dkaparis said.

Android device: Android 7.0, Samsung Galaxy J5 Prime PC: Void Linux i686 Syncthing on PC: v1.1.3, Linux (32 bit) Syncthing on Android: 1.1.2.1

alihardan avatar Jun 03 '19 14:06 alihardan

Hi! I'm also losing changes in a todo.txt file on a regular basis. Since it doesn't happen every time I make a change, it is proving tricky to identify where the problem occurs. I'm using:

Syncthing-Android v1.1.4 SyncTrayzor 1.1.23 on Windows Syncthing 1.1.4 on Linux

If I can narrow it down, I'll post back.

jonniestuefer avatar Jun 17 '19 06:06 jonniestuefer

This should be fixed in the release candidate I think, barring your own fatfingering and modifying stuff on two devices simultaniously.

AudriusButkevicius avatar Jun 17 '19 07:06 AudriusButkevicius

I thought I was experiencing the same bug but then found that conflict files were being created on the phone I just wasn't aware of that, because I was used to getting notification when this happens on PC. When modification on the phone is later than on PC, conflict file is being created silently without notification on desktop or phone. While if modification on PC is later, I get notification on PC.

It would be nice to get conflict notifications on the phone too. Maybe that would be enough to fix this.

sim31 avatar Jan 28 '20 11:01 sim31