Skip to content

Extended attributes are only synced one way #8594

Closed

Description

@mafredri

This happens using Syncthing v1.22.0.

Given two clients, A and B. For a file created by A, extended attribute modifications are only synced from A to B, not from B to A.

So let's say I do the following (Scenario 1):

  1. A: touch test.txt; setfattr -n user.test -v test test.txt
  2. B: setfattr -n user.test2 -v test2 test.txt

Only test.txt on B will have both attributes, it's not being synced from B. The same happens the other way around (Scenario 2):

  1. B: touch test2.txt; setfattr -n user.test -v test test2.txt
  2. A: setfattr -n user.test2 -v test2 test2.txt

Only test.txt on A will have both attributes.

Restarting syncthing makes no difference, this behavior seems set at file creation.

Interestingly, the change is picked up, but not transmitted for some reason (this is B from scenario 1, step 2):

[TWUEC] 2022/10/08 17:54:41.627739 basicfs_watch.go:102: DEBUG: basic /var/syncthing/Test Watch: Sending test.txt non-remove
[TWUEC] 2022/10/08 17:54:41.627784 aggregator.go:296: DEBUG: aggregator/"Test" (errvk-ajxc3): Tracking (type non-remove): test.txt
[TWUEC] 2022/10/08 17:54:41.627804 aggregator.go:315: DEBUG: aggregator/"Test" (errvk-ajxc3): Resetting notifyTimer to 10s
[TWUEC] 2022/10/08 17:54:51.627968 aggregator.go:347: DEBUG: aggregator/"Test" (errvk-ajxc3): Notifying about 1 fs events
[TWUEC] 2022/10/08 17:54:51.628012 aggregator.go:315: DEBUG: aggregator/"Test" (errvk-ajxc3): Resetting notifyTimer to 10s
[TWUEC] 2022/10/08 17:54:51.628094 logfs.go:115: DEBUG: folderconfiguration.go:116 basic /var/syncthing/Test Stat . {0xc0000b7520} <nil>
[TWUEC] 2022/10/08 17:54:51.628204 logfs.go:115: DEBUG: folderconfiguration.go:134 basic /var/syncthing/Test Stat .stfolder {0xc0000b7790} <nil>
[TWUEC] 2022/10/08 17:54:51.628255 logfs.go:163: DEBUG: folder.go:334 basic /var/syncthing/config/index-v0.14.0.db Usage . {2078167924736 2078168711168} <nil>
[TWUEC] 2022/10/08 17:54:51.628434 events.go:334: DEBUG: log 37 StateChanged map[duration:23.628311741 folder:errvk-ajxc3 from:idle to:scan-waiting]
[TWUEC] 2022/10/08 17:54:51.628510 events.go:334: DEBUG: log 38 StateChanged map[duration:0.628361153 folder:errvk-ajxc3 from:scan-waiting to:scanning]
[TWUEC] 2022/10/08 17:54:51.628818 walk.go:123: DEBUG: walker/errvk-ajxc3@0xc0007f20b0 Walk [test.txt] Matcher/[]@0xc0008e6000
[TWUEC] 2022/10/08 17:54:51.628984 walkfs.go:84: DEBUG: walk: path=test.txt
[TWUEC] 2022/10/08 17:54:51.629643 walk.go:423: DEBUG: walker/errvk-ajxc3@0xc0007f20b0 rescan: File{Name:"test.txt", Sequence:22, Permissions:0644, ModTime:2022-10-08 17:54:13.090756718 +0000 UTC, Version:{[{ATW3ZMM 1665251668}]}, VersionHash:, Length:0, Deleted:false, Invalid:false, LocalFlags:0x0, NoPermissions:false, BlockSize:131072, Blocks:[Block{0/0/0/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855}], BlocksHash:d3bfe98e8f1ce891614854569a20f5f4508d6ab4025b872b7b3a8282ef75b12a, Platform:{<nil> <nil> xattrs:<name:"user.test1" value:"test1" >  <nil> <nil> <nil>}} 1665251653 -rw-r--r--
[TWUEC] 2022/10/08 17:54:51.629705 walk.go:426: DEBUG: walker/errvk-ajxc3@0xc0007f20b0 to hash: test.txt File{Name:"test.txt", Sequence:0, Permissions:0644, ModTime:2022-10-08 17:54:13.090756718 +0000 UTC, Version:{[{ATW3ZMM 1665251668} {TWUECHX 1665251691}]}, VersionHash:, Length:0, Deleted:false, Invalid:false, LocalFlags:0x0, NoPermissions:false, BlockSize:131072, Blocks:[], BlocksHash:, Platform:{<nil> <nil> xattrs:<name:"user.test1" value:"test1" > xattrs:<name:"user.test2" value:"test2" >  <nil> <nil> <nil>}}
[TWUEC] 2022/10/08 17:54:51.629814 walk.go:198: DEBUG: walker/errvk-ajxc3@0xc0007f20b0 real to hash: test.txt
[TWUEC] 2022/10/08 17:54:51.630085 walk.go:176: DEBUG: walker/errvk-ajxc3@0xc0007f20b0 Walk progress done errvk-ajxc3 [test.txt] Matcher/[]@0xc0008e6000
[TWUEC] 2022/10/08 17:54:51.630182 logfs.go:115: DEBUG: folderconfiguration.go:116 basic /var/syncthing/Test Stat . {0xc000379e10} <nil>
[TWUEC] 2022/10/08 17:54:51.630244 logfs.go:115: DEBUG: folderconfiguration.go:134 basic /var/syncthing/Test Stat .stfolder {0xc001533c70} <nil>
[TWUEC] 2022/10/08 17:54:51.630309 logfs.go:163: DEBUG: folder.go:334 basic /var/syncthing/config/index-v0.14.0.db Usage . {2078167924736 2078168711168} <nil>
[TWUEC] 2022/10/08 17:54:51.630687 events.go:334: DEBUG: log 39 LocalIndexUpdated map[filenames:[test.txt] folder:errvk-ajxc3 items:1 sequence:23 version:23]
[TWUEC] 2022/10/08 17:54:51.630735 events.go:334: DEBUG: log 40 LocalChangeDetected map[action:modified folder:errvk-ajxc3 folderID:errvk-ajxc3 label:Test modifiedBy:TWUECHX path:test.txt type:file]
[TWUEC] 2022/10/08 17:54:51.630889 events.go:334: DEBUG: log 41 StateChanged map[duration:0.630799815 folder:errvk-ajxc3 from:scanning to:idle]
[TWUEC] 2022/10/08 17:54:52.594940 events.go:334: DEBUG: log 42 FolderSummary {errvk-ajxc3 0xc000c5b4a0}
[TWUEC] 2022/10/08 17:54:52.595076 events.go:334: DEBUG: log 43 FolderCompletion map[completion:100 device:ATW3ZMM-DJ3APTY-WA372XM-4KMWDNX-TNGCN7W-NTE543B-5IJRG7D-QLNLLAY folder:errvk-ajxc3 globalBytes:0 globalItems:1 needBytes:0 needDeletes:0 needItems:1 remoteState:valid sequence:37]
[TWUEC] 2022/10/08 17:55:01.628904 aggregator.go:323: DEBUG: aggregator/"Test" (errvk-ajxc3): No tracked events, waiting for new event.

Activity

  1. added
    bug
    needs-triage
    on Oct 8, 2022
  2. calmh commented on Oct 8, 2022

    @calmh
    Member

    FWIW this doesn't reproduce for me on macOS, things get synced properly in both directions. What OS and filesystem are you testing on?

  3. mafredri commented on Oct 8, 2022

    @mafredri
    Author

    FWIW this doesn't reproduce for me on macOS, things get synced properly in both directions. What OS and filesystem are you testing on?

    Interesting, I could've sworn I saw this behavior between macOS and a macOS VM as well.

    The above was done on Linux with ZFS on both sides (Syncthing running in Docker).

  4. calmh commented on Oct 8, 2022

    @calmh
    Member

    Allright, Linux on ext4 also doesn't show this issue for me, though I'm not testing with Docker involved.

  5. mafredri commented on Oct 8, 2022

    @mafredri
    Author

    Ok, looks like my initial analysis was wrong (sorry about that) and I ran into two things:

    1. Extended attribute syncing does not work properly in the following scenario: L1 talks to L2 only, L2 talks to L1 and M1, M1 talks to L2 and M2, M2 talks to M1 only (L = Linux, M = Mac)
    2. A chmod permission error preventing xattrs from being applied

    So obviously the latter is user error 🤦🏻.

    But in 1), I'm not sure how many clients are required, but that's the setup I have currently. I believe it was only L1 <-> L2 <-> M1 when I first ran into the issue and started digging (and then creating the second issue in the process).

    So let's say I do the following:

    1. M1: touch test.txt
    2. L2: setfattr -n user.test -v test test.txt
    3. L1: setfattr -n user.test2 -v test2 test.txt

    Then user.test is never propagated to L1 and user.test2 is never propagated to L2.

    Similarly creating a file on L2 breaks xattrs between M1/M2.

  6. mafredri commented on Oct 8, 2022

    @mafredri
    Author

    Hmm, that's weird. If we continue on those steps:

    1. M1: touch test.txt
    2. L2: setfattr -n user.test -v test test.txt
    3. L1: setfattr -n user.test2 -v test2 test.txt
    4. L2: rm test.txt

    After 4) test.txt will re-appear on L2 with the user.test2 attr from L1. So it seems there's a sync issue leaving it in limbo, but Syncthing is reporting "Up to date" on all 4 machines.

  7. calmh commented on Oct 8, 2022

    @calmh
    Member

    Yes, there is a weirdness. Looking into it.

  8. removed
    needs-triage
    on Oct 8, 2022
  9. calmh commented on Oct 8, 2022

    @calmh
    Member

    OK, so here's the thing (FYI myself and other developers)... I thought I was clever when I crafted the comparisons for xattrs and ownership, in that we only consider a file info different if it's set on both sides -- otherwise a file would be unequal and require resync as soon as it's synced to a new operating system and new attributes picked up. But precisely that actually needs to happen, otherwise we don't send out the change when a file comes from linux and we add attributes on macos, and things like that. We need to pick up those attributes and send back the changed file. There are details in making that happen properly that I'll hopefully be able to deal with, PR upcoming at some point tomorrowish...

    One potentially interesting side effect is a cluster with two sendOwnership or sendXattrs devices won't work. Device A will send a file with some ownership information, device B will sync the file and not apply the ownership information, then pick up its own ownership info and send that, which will cause a resync on A where it doesn't apply the ownership info but sends out a new update with its own ownership info and then goto 10

  10. self-assigned this
    on Oct 11, 2022
  11. added a commit that references this issue on Oct 16, 2022
    d3f5063
  12. added this to the v1.22.1 milestone on Oct 17, 2022
  13. added a commit that references this issue on Nov 8, 2022
    db49472
  14. added
    frozen-due-to-age
    on Oct 16, 2023
  15. locked and limited conversation to collaborators on Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfrozen-due-to-age

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions