Skip to content

Adding a folder that has previously been removed causes errors and odd behavior #9595

Closed as not planned

Description

@dpedu

What happened?

tl;dr:

  1. Folder shared between two syncthing instances, A & B
  2. B instance removes the folder and the user purges local data
  3. A instance removes B from the list of peers the folder is shared with
  4. A instance adds B back to the list of peers the folder is shared with
  5. B accepts the share via UI
  6. B fails to create the directory at the path specified, causing syncthing to put the folder into the Stopped state and raise an error. Syncthing is behaving as if the folder was previously operating normally and was deleted out from under it.

Reproduction steps: I used two syncthing instances running via docker compose to reproduce this:

version: '3.8'

services:
  syncthingA:
    image: syncthing/syncthing:1.27.8
    ports:
      - "9001:8384"

  syncthingB:
    image: syncthing/syncthing:1.27.8
    ports:
      - "9002:8384"

Steps:

Connected the two instances:

  • On A, Actions -> Show ID, copy it
  • On B, Add Remote Device, paste in the ID, Save
  • On A, Add Device via the notification, Save

Create, share, and populate a test folder:

  • On A, Add Folder -> Label "testfolder", Sharing -> check the B device, Save
  • On B, Add folder via the notification, Accept
  • Exec into the A container and add some files to the shared dir. I create them in a scratch dir so I can chown them appropriately for the 1000:1000 user the docker container runs syncthing as by default, and then move the files into the shared dir
docker exec -it syncthing-bug_syncthingA_1 sh
mkdir scratch
cd scratch
date > foo.txt
echo "lol" > bar.txt
dd if=/dev/random of=./test.bin bs=1000 count=8
chown 1000:1000 *
mv * /var/syncthing/testfolder/
# ls -la /var/syncthing/testfolder/
total 28
drwxr-xr-x    3 1000     1000          4096 Jun 27 20:11 .
drwxr-xr-x    5 1000     1000          4096 Jun 27 20:09 ..
drwxr-xr-x    2 1000     1000          4096 Jun 27 20:08 .stfolder
-rw-r--r--    1 1000     1000             4 Jun 27 20:11 bar.txt
-rw-r--r--    1 1000     1000            29 Jun 27 20:10 foo.txt
-rw-r--r--    1 1000     1000          8000 Jun 27 20:11 test.bin
  • Go to B ui, wait until the files are synced over

Remove the shared folder on one device:

  • On B, Edit testfolder and Remove it
  • Exec into the B container and delete the data that was synced over
  • docker exec -it syncthing-bug_syncthingB_1 sh
ls -la /var/syncthing/testfolder/ # you should also see that synchthing has removed the .stfolder
rm -rf /var/syncthing/testfolder/

Trigger the bug:

  • On A, edit testfolder and remove B as a shared device
  • On A, edit testfolder and add B as a shared device back again
  • On B, accept the folder via the notification, Save as-is
  • Observe that testfolder is added, but goes into the Stopped state and a error notification comes up saying
2024-06-27 13:17:14: Error on folder "testfolder" (xca2n-253op): folder path missing
  • In the B container, observe that syncthing did not create /var/syncthing/testfolder/

Expected behavior:

  • Syncthing is able to accept the share like any other and start syncing data

Workarounds:

  • Removing the folder via B's UI, Killing B syncthing and restarting it allows the folder to be accepted successfully again.
  • If you restart either syncthing instance after removing the folder from B the first time, it can be accepted successfully again.

Syncthing version

v1.27.8

Platform & operating system

Linux arm64 and macOs arm64

Browser version

N/A

Relevant log output

syncthingA_1  | [KW6ED] 2024/06/27 20:34:01 INFO: Ready to synchronize "testfolder" (pk7nv-kdndv) (sendreceive)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:01 INFO: Restarted folder "testfolder" (pk7nv-kdndv) (sendreceive)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:01 INFO: Completed initial scan of sendreceive folder "testfolder" (pk7nv-kdndv)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:06 INFO: Ready to synchronize "testfolder" (pk7nv-kdndv) (sendreceive)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:06 INFO: Restarted folder "testfolder" (pk7nv-kdndv) (sendreceive)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:06 INFO: Device KW6EDJU folder "testfolder" (pk7nv-kdndv) has mismatching index ID for us (0xAF88B634ADDBF216 != 0x0000000000000000)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:06 INFO: Device KW6EDJU folder "testfolder" (pk7nv-kdndv) has a new index ID (0x5B6B86B819A21C3C)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:06 INFO: Unexpected folder "testfolder" (pk7nv-kdndv) sent from device "KW6EDJU-5WTOXJ4-4UBVPQS-3ZZPAVG-Y2NTRE2-LJXGKH5-C64GVD7-FKTTPAT"; ensure that the folder exists and that this device is selected under "Share With" in the folder configuration.
syncthingA_1  | [KW6ED] 2024/06/27 20:34:06 INFO: Completed initial scan of sendreceive folder "testfolder" (pk7nv-kdndv)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:06 INFO: Detected 1 NAT service
syncthingB_1  | [2UCK3] 2024/06/27 20:34:07 INFO: Detected 1 NAT service
syncthingB_1  | [2UCK3] 2024/06/27 20:34:09 INFO: Adding folder "testfolder" (pk7nv-kdndv)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:09 INFO: Ready to synchronize "testfolder" (pk7nv-kdndv) (sendreceive)
syncthingA_1  | [KW6ED] 2024/06/27 20:34:09 INFO: Device 2UCK3MF folder "testfolder" (pk7nv-kdndv) has a new index ID (0x3000823090B0B31B)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:09 INFO: Failed initial scan of sendreceive folder "testfolder" (pk7nv-kdndv)
syncthingB_1  | [2UCK3] 2024/06/27 20:34:09 WARNING: Error on folder "testfolder" (pk7nv-kdndv): folder marker missing (this indicates potential data loss, search docs/forum to get information about how to proceed)

Verbose log (STTRACE=all): syncthing-127.log

Activity

  1. added
    bug
    needs-triage
    on Jun 27, 2024
  2. dpedu commented on Jun 27, 2024

    @dpedu
    Author
  3. lingmann commented on Oct 5, 2024

    @lingmann

    Also seeing this exact issue with two devices running Syncthing v1.27.12 The workaround of "Removing the folder via B's UI, Killing B syncthing and restarting it allows the folder to be accepted successfully again." made it possible for me to get the two folders syncing properly again.

  4. tomasz1986 commented on Nov 24, 2024

    @tomasz1986
    Member

    Closing as I'm almost certain that this is the exact same bug as reported in #8416. However, in that issue I will link to the post by @dpedu above, which seems to include useful information that could possibly help debug this quite annoying problem further.

  5. dpedu commented on Mar 20, 2026

    @dpedu
    Author

    This appears to be fixed in 025905f.

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

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions