Skip to content

Conversation

@imsodin
Copy link
Member

@imsodin imsodin commented Sep 7, 2024

The test is quite odd and specific, but it does reproduce the issue that caused #9677, so I'd propose to add it to have a simple regression test for the basic scenario. Also the option to the fakefs might come handy for other scenarios where you want to quickly test some behaviour on a filesystem without nanosecond precision, without actually needing access to one.

@imsodin imsodin force-pushed the fs/repro-missing-mtimefs branch 2 times, most recently from 43a1a29 to 0773582 Compare September 7, 2024 21:35
lib/fs/fakefs.go Outdated
return os.ErrNotExist
}
if fs.timePrecisionSecond {
mtime = mtime.Round(time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were a file system this would be truncate and not round, but I guess as this is the more evil behavior it might be better in fakefs :p

}
}

func TestRepro9677(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pet peeve, explain what the test is supposed to test :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added something to the name that could give a hint, and wrote a comment trying to explain it.

Doing so I noticed another thing: We create an FS key for cached FS that includes options. So a FS with and without mtimefs should produce distinct keys, preventing everything we saw?! Clearly I am either misunderstanding what that key mechanism does or it's broken. I'll have a look at that too.

Copy link
Member Author

@imsodin imsodin Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, mtime FS "swallows" it's own option, thus it's not included in the cache key. So instead of only caching the cache, I could also fix the cache key, in one of two ways (or both): Include the types of underlying/wrapped filesystems in the key. And/or add the mtime option to the Filesystem.Options result. I'll probably do both regardless, seems like the right thing to do.

Or no, neither. Adding an option for the mtime FS wrapper is inconsistent, we don't do it for other wrappers either. And considering wrapped filesystems in the case FS cache makes sense, but I prefer not caching the filesystem at all, rendering the change moot.

@imsodin imsodin force-pushed the fs/repro-missing-mtimefs branch from 0773582 to 4b9e37f Compare September 8, 2024 08:18
@calmh calmh merged commit 29f7510 into syncthing:main Sep 10, 2024
@calmh calmh added this to the v1.27.13 milestone Sep 11, 2024
imsodin added a commit to imsodin/syncthing that referenced this pull request Sep 12, 2024
This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
imsodin added a commit to imsodin/syncthing that referenced this pull request Sep 12, 2024
This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
imsodin added a commit to imsodin/syncthing that referenced this pull request Sep 12, 2024
This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
calmh pushed a commit that referenced this pull request Sep 12, 2024
This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in #9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: #9677
Followup to: #9687
leoon-ding pushed a commit to leoon-ding/syncthing that referenced this pull request Mar 19, 2025
…hing#9701)

This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants