Repository navigation
fix(posix): retry a failed file once its ctime changes - #809
Merged
aduffeck merged 2 commits intoOct 14, 2026
Merged
Conversation
3 of 9 tasks
aduffeck
requested changes
Oct 13, 2026
aduffeck
left a comment
Member
There was a problem hiding this comment.
lgtm besides the timemanager.StatCTime() fix.
A file that fails to assimilate is skipped while its mtime, size, mode and owner stay the same, with a delay that doubles up to 24h. A fix that changes none of those fields went unnoticed until the delay ran out or the service restarted. setfacl and chattr -i are the common ones, and a copy that replaces the file with the same attributes behaves the same way. The failure cache now also keeps the ctime, read after the failed attempt so that the attributes the attempt did write are already in it. Any later change to the file or its attributes moves the ctime on, and the next scan tries the file again. The delay keeps doubling when only the ctime changed, so a file that gets fixed again and again costs one read per fix. When the file cannot be read again the ctime stays unknown and only the attributes decide, which is what happens on a system that reports no ctime as well. The spec for the skip found reads through the access time, which no longer works: changing the access time changes the ctime as well. It counts the bytes this process read instead, from /proc/self/io, and skips where that file is missing. Fixes opencloud-eu#805
NickWalters
force-pushed
the
fix/posix-assimilation-ctime
branch
from
October 14, 2026 02:19
5082655 to
061f2e2
Compare
aduffeck
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #805, a follow-up to #796.
Problem
#796 skips a file that failed to assimilate while its mtime, size, mode and owner stay the same. The retry delay starts at 1 minute and doubles up to 24h. A fix that changes none of those fields goes unnoticed until the delay runs out or the service restarts.
setfaclandchattr -iare the common ones. A copy that replaces the file with the same attributes waits just as long.How to reproduce
group::entry isr--for a group the service user is in.failed to set ... xattrs ... permission denied.setfacl -m g::rwX <file>. The mode, owner, size and mtime don't change.item is unchanged since it failed to assimilate, not retrying before <time>until the delay runs out.On 8.1.0 this hit 136 files here (details in #805).
Fix
Recordreads the file again after the failed attempt and keeps that ctime, andunchangedcompares it. Any later change to the file or its attributes moves the ctime on, so the next scan tries the file again. It usestimemanager.StatCTime, so the platform split stays in one place.The ctime is read after the attempt on purpose. An attempt that sets some attributes and then fails has already moved the ctime. A value from before the attempt would never match again, and every scan would read the whole file. If the stat fails, the ctime stays unknown and only the attributes decide, as on a system with no ctime.
The doubling check uses the attributes only. So a change that shows only in the ctime keeps the doubled delay instead of starting again at 1 minute. A file that is fixed, retried and fails again costs one read per fix.
Trade-off
The recorded state has the attributes from before the attempt and the ctime from after it. A bulk
setfacl -Rthat lands while a large file is being read for its checksum gets absorbed into the recorded ctime, and that file waits for its retry. A ctime from before the attempt would bring back the retry loop above, which is worse.Tests
The spec in
tree_non_watching_test.godetected reads through the access time. That no longer works, because changing the access time also changes the ctime. It now counts the bytes this process read from/proc/self/io, with a file big enough that nothing else explains them, and skips where/proc/self/iois missing. It also checks that a chmod to the mode the file already has (whatsetfaclandchattrlook like from here) makes the file get read again.Both specs chmod until the ctime has really moved, because some kernels stamp it from a coarse clock.
go test -race ./pkg/storage/fs/posix/...passes locally, golangci-lint is clean, and the read-detection spec ran five times without a flake.Notes
This conflicts with #853 on one import line in
tree_non_watching_test.go. I'll rebase whichever one goes second.