Global and local state mismatch (v2)

Got a mismatch between global and local state for one folder:

No errors on any side, all up to date, other side has the same amount of folders/files as the local state in the screenshot (11882/701) for both local and global state so I guess everything is in sync and only global state is wrong.

Folder status in the API:


{
  "errors": 0,
  "pullErrors": 0,
  "invalid": "",
  "globalFiles": 12630,
  "globalDirectories": 713,
  "globalSymlinks": 0,
  "globalDeleted": 28376,
  "globalBytes": 954143970523,
  "globalTotalItems": 41719,
  "localFiles": 11882,
  "localDirectories": 701,
  "localSymlinks": 0,
  "localDeleted": 10960,
  "localBytes": 954143968987,
  "localTotalItems": 23543,
  "needFiles": 0,
  "needDirectories": 0,
  "needSymlinks": 0,
  "needDeletes": 0,
  "needBytes": 0,
  "needTotalItems": 0,
  "receiveOnlyChangedFiles": 0,
  "receiveOnlyChangedDirectories": 0,
  "receiveOnlyChangedSymlinks": 0,
  "receiveOnlyChangedDeletes": 0,
  "receiveOnlyChangedBytes": 0,
  "receiveOnlyTotalItems": 0,
  "inSyncFiles": 12630,
  "inSyncBytes": 954143970523,
  "state": "idle",
  "stateChanged": "2025-06-07T17:10:53+02:00",
  "error": "",
  "version": 64934,
  "sequence": 64934,
  "remoteSequence": {
    "2X5ZKRO-...": 70568
  },
  "ignorePatterns": false,
  "watchError": ""
}

Already tried --debug-reset-delta-idxs but no change. Remote device is still on v1. Should I send the database or anything else I can try?

1 Like

Definitely send me the database! :folded_hands:

syncthing debug database-statistics

will tell you which is the relevant file for the folder in question

Thanks for sending the database, it really helps getting to the bottom with these things. Looking at the database, we can see that things line up mostly, expect for one oddity:

sqlite> select * from counts where type = 0 and not deleted and local_flags & 16 != 0;
device_idx  type  local_flags  count  size          deleted
----------  ----  -----------  -----  ------------  -------
1           0     16           11882  954143879259  0 <-- local files
27          0     16           748    0             0 <-- additional remote files
27          0     48           0      0             0

We can see that there are 748 extra files (12630 - 11882 = 748) with zero size announced by the other side, which are not applied locally. What are those?

sqlite> SELECT name from files where device_idx=27 and type=0 and deleted=0 and local_flags=16;
...
$RECYCLE.BIN/S-1-5-21-<numbers>/$RYS14QE.jpg
... 747 similar entries

So, deleted files in the recycle bin (but not deleted from the filesystem as far as Syncthing is concerned). Question is, why are they just accounted and ignored? Ah, wait, they all have the invalid bit set.

Presumably they are ignored on the other side and have existed at some point and are still announced for accounting reasons. We shouldn’t be considering them part of the global state when they have the invalid bit set. This looks like a bug.

2 Likes

I guess the history of those files is the following:

  • create folder on remote side (Windows), forgot to add $RECYCLE.BIN to ignore patterns
  • sync to linux machine (the one with broken global state)
  • add ignore pattern on Windows
  • delete files on linux
3 Likes

Yep, that explains it completely. I see the problem, will fix, thanks for reporting!

6 Likes

Thanks :slight_smile:

2 Likes

Wait, have we finally found the cause of the dreaded “stuck at 95%” problem?

Nope, this is a minor v2 regression.