Skip to content

File will be deleted when renamed after moving into newly created folder #7032

Closed

Description

@BeayemX

Does your log mention database corruption?

No

Include required information

$ syncthing --version
syncthing v1.10.0 "Fermium Flea" (go1.15.2 linux-amd64) [email protected] 2020-09-15 17:38:23 UTC [noupgrade]

OS in which the actions took place
Linux Mint 20 ulyana

Other synced OS

  • Ubuntu 18.04 bionic
  • Raspbian 9.13 stretch

All systems use the same version of syncthing

What happened

  1. Create a new folder
  2. Move a file that is already synced into the newly created folder
  3. Rename the moved file (different name, not just changing the case)
  4. After some time the file was deleted

The issue happend twice to me already (at least where I noticed it) when I was reorganizing my files.
But I can not reproduce it.

Activity

  1. added
    bug
    needs-triage
    on Oct 12, 2020
  2. AudriusButkevicius commented on Oct 12, 2020

    @AudriusButkevicius
    Member

    Are you able to reproduce this with 2 devices?
    Do all actions happen on the same device?

  3. BeayemX commented on Oct 12, 2020

    @BeayemX
    Author

    All actions happen on the same device.
    The actions happend in a matter of seconds one after another.

    Sadly I can't reproduce the error.

  4. AudriusButkevicius commented on Oct 12, 2020

    @AudriusButkevicius
    Member

    If it's not something that can be reproduced, I am not sure if its something we can fix.

  5. BeayemX commented on Oct 13, 2020

    @BeayemX
    Author

    Could it be that there is some kind of race condition?

    • Device 1 moves file
    • Device 2 removes file in the process of moving
    • Device 1 renames file
    • Device 2 wants to create the moving file but detects that the file with the desired name does not exist any more on device 1
    • Device 2 sends out information that the file has been removed
    • Device 1 deletes file accordingly to Device 2's information

    I have not the slightest idea if Syncthing works this way, but that would be the only way that would kind of explain the issue.

  6. AudriusButkevicius commented on Oct 13, 2020

    @AudriusButkevicius
    Member

    Moves are represented as a create followed by a deleted, which is then optimised to a rename on the receiving side.

    I guess if you have some luck reproducing this, I'd be interesting to run with STTRACE=model env var on both sides and compare the output when this happens and when it doesn't.

    I have no doubt it might be a race condition, but I can't clearly see it, because things in syncthing happens in cycles, so it's either trying to pull (download all of the files outstanding), or scanning (and sending changes it detects).

    In your scenario scanning and pulling happens at the same time, which I think is impossible.
    If anything, I'd atleast expect to see some errors in the log about file modified but not rescanned, etc.

    I guess it might be hard to reproduce this synthetically, as probably your setup hits some lucky timings to exercise the race condition.

  7. BeayemX commented on Oct 13, 2020

    @BeayemX
    Author

    While trying to reproduce the error I came across some other weird behaviour.

    I created a Folder (initial name Untitled Folder) and renamed it to Test.
    But the rename was not synced.
    When I renamed the folder Test to Test2 the remove command for Untitled Folder was logged
    (see the last 3 lines of the log)

    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Ignoring ADelTest/Untitled Folder/.syncthing.Pi.md.tmp
    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Ignoring ADelTest/Untitled Folder/.syncthing.Pi.md.tmp
    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Ignoring ADelTest/Untitled Folder/.syncthing.Pi.md.tmp
    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/Pi.md non-remove
    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Ignoring ADelTest/Untitled Folder/.syncthing.Pi.md.tmp
    2020-10-13 23:23:49 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/Pi.md non-remove
    2020-10-13 23:23:59 folder.go:297 basic /home/christian/.config/syncthing/index-v0.14.0.db Usage . {33662697472 137611730944} <nil>
    2020-10-13 23:24:28 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/.goutputstream-F01LS0 non-remove
    2020-10-13 23:24:28 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/.goutputstream-F01LS0 non-remove
    2020-10-13 23:24:28 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/.goutputstream-F01LS0 non-remove
    2020-10-13 23:24:28 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/Pi.md non-remove
    2020-10-13 23:24:28 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder/.goutputstream-F01LS0 remove
    2020-10-13 23:24:38 folder.go:297 basic /home/christian/.config/syncthing/index-v0.14.0.db Usage . {33662570496 137611730944} <nil>
    2020-10-13 23:24:38 folder.go:297 basic /home/christian/.config/syncthing/index-v0.14.0.db Usage . {33662570496 137611730944} <nil>
    2020-10-13 23:25:03 basic /home/christian/Sync Watch: Sending ADelTest/Untitled Folder remove
    2020-10-13 23:25:03 basic /home/christian/Sync Watch: Sending ADelTest/Test2 non-remove
    2020-10-13 23:25:03 basic /home/christian/Sync Watch: Sending ADelTest/Test remove
    
    
  8. AudriusButkevicius commented on Oct 13, 2020

    @AudriusButkevicius
    Member

    Directories are never renamed, and they are deleted and recreated, only files are renamed.
    So if you rename a large directory tree, we'd pre-create the new directories, rename all the files, and remove old directories.

    I guess if you are trying to repro this through the prism of the filesystem, you'll probably have an indication of this happening, but it won't help answer why it happened, as the race condition most likely lives in the model.

  9. BeayemX commented on Oct 29, 2020

    @BeayemX
    Author

    I think the issue is caused by using Nemo (the default file browser on Linux Mint).
    The issue occured a few more times. Only when I created a new folder with Nemo and never when I created a folder from VS code or the command line.

    I think it is caused by the behaviour that Nemo creates the actual folder on the disk with the placeholder name Untitled Folder and after you enter your desired folder name, it renames the folder.

    The other programs create the folder initially with the desired name, so there is no rename happening.

    I am not sure if this is helpful, but it's something I noticed...

  10. AudriusButkevicius commented on Oct 30, 2020

    @AudriusButkevicius
    Member

    This doesn't really help understanding the problem. I suggest you look at the debugging facilities I suggested as you try and make a reproducer for this.

    Sadly if there is no way for us to reproduce this, or no logs explaining the issue, I'll have to close this as we can't fix something we can't see.

  11. BeayemX commented on Oct 31, 2020

    @BeayemX
    Author

    Maybe a related issue #6293

  12. imsodin commented on Nov 24, 2020

    @imsodin
    Member

    Unless there's a definite way to reproduce this or logs with the debugging facilities requested above enabled while it happens, there's nothing that can be done about this issue. Please open a topic on the forum for more help on how to debug this or if you do have a reproducer or the required logs, feel free to post them and re-open this issue.

  13. added
    frozen-due-to-age
    on Nov 25, 2021
  14. locked and limited conversation to collaborators on Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-ageneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions