"Out of sync" masters while syncing with an android phone

#1

Sadly I get regulary out of sync errors for files which didn’t changed. I force the sync at the master, but at the next day I get the same error.

Only the masters are getting these errors, I assume because the other ones getting the “new state” of the files from the android phone.

I get this behaviour since months but finally got time to report it.

I would be very glad if some could help me.

Slave vfat Android 9.0 (OmniROM)

stat xxx.jpg

File: `xxx.jpg’

Size: 601064 Blocks: 1216 IO Blocks: 512 regular file

Device: b301h/45825d Inode: 108391 Links: 1

Access: (770/-rwxrwx—) Uid: ( 1023/media_rw) Gid: ( 1023/media_rw)

Access: 2015-07-14 00:00:00.000000000

Modify: 2015-07-14 22:39:42.000000000

Change: 2019-05-07 10:38:22.000000000

Master ext4 Linux Mint 19.1 (Ubuntu 18.04; 4.18.0-18-generic)

stat xxx.jpg

File: xxx.jpg

Size: 601064 Blocks: 1176 IO Blocks: 4096 regular file

Device: 804h/2052d Inode: 2886257 Links: 1

Access: (0644/-rw-r–r--) Uid: ( 1000/ martin) Gid: ( 1000/ martin)

Access : 2019-05-08 10:21:26.441523414 +0200

Modify: 2015-07-14 22:39:43.818750000 +0200

Change : 2019-03-07 10:43:58.304522864 +0100

Birth : -

PS: I love syncthing (android) !

(Simon) #2

Those file indeed look exactly the same except for permissions. So the first thing you need to check is if you have set ignore permissions (though I hope/expect the android wrapper sets that by default). If that is already checked, please query the REST interface for one of the out-of-sync files on the master and post the results here: https://docs.syncthing.net/rest/db-file-get.html

#3

Thank you for your reply. :slight_smile:

The “ignoring permission” is set in the android app, but not in my linux syncthing.

I am feeling a bit lost at the rest results, since I don’t get the same result as shown in the docs.

curl -X GET -H “X-API-Key: xxx” http://localhost:8080/rest/db/file?folder=finanzen&file=data.mmb

[1] 29817

Regularly creates sync conflicts for untouched files
#4

You need to quote the URL, so the & isn’t interpreted as “run in background”, which resulted in a background job with the process id 29817.

If you have more than one master, hitting override on one of them with trigger the out of sync on the other, and hitting override on that one will trigger out of sync on the first one.

#5

Woopsi, thank you!

curl -X GET -H "X-API-Key: szdcpc1sd713a9hjd40s5v5w53n5eo" "http://localhost:8080/rest/db/file?folder=finanzen&file=data.mmb"
    {
      "availability": [
        {
          "id": "xxx",
          "fromTemporary": false
        }
      ],
      "global": {
        "deleted": false,
        "ignored": false,
        "invalid": false,
        "localFlags": 0,
        "modified": "2019-05-06T10:38:00+02:00",
        "modifiedBy": "ZYVKCS2",
        "mustRescan": false,
        "name": "data.mmb",
        "noPermissions": true,
        "numBlocks": 7,
        "permissions": "0750",
        "sequence": 236,
        "size": 805888,
        "type": 0,
        "version": [
          "C33LCQ4:2065",
          "KMTEDOF:1",
          "ULRKADL:2",
          "WPQYJTV:833",
          "YHL5CKE:2",
          "YHWFSLJ:9",
          "ZLG3V2O:1",
          "ZYVKCS2:28",
          "3B3RCE4:53",
          "3LKJBFR:1"
        ]
      },
      "local": {
        "deleted": false,
        "ignored": false,
        "invalid": false,
        "localFlags": 0,
        "modified": "2019-05-06T10:38:01.458109919+02:00",
        "modifiedBy": "C33LCQ4",
        "mustRescan": false,
        "name": "data.mmb",
        "noPermissions": false,
        "numBlocks": 7,
        "permissions": "0664",
        "sequence": 2254,
        "size": 805888,
        "type": 0,
        "version": [
          "C33LCQ4:2065",
          "KMTEDOF:1",
          "ULRKADL:2",
          "WPQYJTV:833",
          "YHL5CKE:2",
          "YHWFSLJ:9",
          "ZLG3V2O:1",
          "ZYVKCS2:27",
          "3B3RCE4:53",
          "3LKJBFR:1"
        ]
      }
    }

Woops, I mean I have on one device 3 masters and all of them getting the regularly an “out of sync” error. They are the only master for the specific directory in the cluster.

(Audrius Butkevicius) #6

Device with id ZYVKCS2 did genuinely modify the file.

(Audrius Butkevicius) #7

Actually the rounding in the global timestamp implies loss of accuracy which should not happen with that mtimeFs.

(Jakob Borg) #8

Due to lack of ignorePermissions? We don’t do the equivalent of an noPermissionsFs, iirc.

(Audrius Butkevicius) #9

Out if sync because of the flag difference? (On global no permissions is set and I assume last modified is android)

(Jakob Borg) #10

Oh my bad, I didn’t see the noPermissions: true. (I thought we set the permission bits to 0666 or 0644 or something when ignore permissions was true, not 0750 like in that one.)

So I was thinking Syncthing set 0664 on it and picked up 0750 as a difference on next scan.

#11

Do you guys need more infos from my side? Did I do something wrong or is it maybe a syncthing or aosp bug?

(Audrius Butkevicius) #12

@calmh @imsodim does this not look like mtime workaround or no permissions check not working?

@MartinX3 are you sure ignore permissions was enabled from the beginning?

#13

@AudriusButkevicius I didn’t changed the option in the android app (and I would need the webview to access it). If it was the default since the beginning, it should be activated since the beginning.

Can I help you with something else?

(Jakob Borg) #14

It does look like that. But I think we’d have more complaints if it didn’t, completely. FAT is “extreme” with its even-second-only precision, but internally we do all timestamps in nanosecond precision and would fail equally on the lots of filesystems out there that provide milli- or microseconds only.

I suspect Android shenanigans. Maybe it returns the value we set, from cache, when we read it back and then only later show the real value from the filesystem. :man_shrugging:

#15

Should I activate the noPerimissionCheck on the linux ext4 machine, too?

(Audrius Butkevicius) #16

It’s not clear if that will help.

I don’t have a phone with an SD card to look into this, as I assume FAT is only used for the sd card.

#17

My /data is mounted as ext4

My /data/media is mounted as sdcardfs (ext4 partition)

My sdcard is mounted as sdcardfs, too (fat32 partition)

(Audrius Butkevicius) #18

Sadly I think you are on your own here, as I have no means to reproduce this on my phone (nor am I heavily interested in pursuing this).

I am surprised you can even write to am sd card, but I guess you can always try formatting your sd card to use a modern filesystem.

Android will always stay a second class citizen for syncthing. Original android developers made a ton of bad decisions, followed by tons of vendors modifying the OS making it a platform on which it’s impossible to make sensible assumptions, and sadly the users are the ones that have to live with the reality of this.

#19

Sad to hear. :frowning:

Which format system do you recommend? fat32 has open source tools and is good to use. exfat is proprietary and because of that if you want to check the sdcard, because the filesystem is dirty, AOSP/OmniROM runs amok. ntfs has journaling -> killing flash storage cells. ext4 is ssd aware, but also isn’t enabled for sdcard usage in AOSP. :frowning:

It is different on closed source stock firmwares from device vendors, they can just throw closed source binaries in it to “fully” support exfat. But in my case the filesystem should be supported in aosp and good for flash storages. Since I am a linux user, it is fine for me to format it.

hmmmmmmm, yeah, luckily google runs into the mainline direction for android with each new big android version. (hoping fuchsia the closed source friend will never land).

#20

If your sd card is good / fast enough, you can format it as “internal” in android. That way, you cannot take it out and put it in another device, as it is encrypted and formatted as ext4. It will replace your current /storage/emulated/0/. That’s what I did, when I had a device with sd card and little internal storage.

If the card is not good / fast enough, your system will be unstable.