filer.remote.sync: say that any saved offset wins over the creation time

The creation time in seconds was compared with the offset in
milliseconds, which made any saved offset win. That is the behaviour to
keep: remote.unmount recreates the directory and then saves the offset,
usually in the same second, so a seconds comparison would start at the
creation second and replay the purge. The comparison now states it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-11-06 01:28:09 -08:00
1 parent f888ac6b8f
commit a0d60ee00f
2 files changed
+14 -1

No files matched your search

+3 -1
View File
@@ -1145,7 +1145,9 @@ func resolveLastSyncOffset(mountedDir string, timeAgo time.Duration, lookupMount
return time.Time{}, fmt.Errorf("read the sync offset of %s: %w", mountedDir, err)
}
if mountedDirEntry != nil {
if mountedDirEntry.Attributes.Crtime < lastOffsetTsNs/1000000 {
// a saved offset wins even over a newer creation time: remote.unmount
// saves one after recreating the directory, often in the same second
if lastOffsetTsNs > 0 {
lastOffsetTs = time.Unix(0, lastOffsetTsNs)
glog.V(0).Infof("resume from %v", lastOffsetTs)
} else {
@@ -658,6 +658,17 @@ func TestResolveLastSyncOffsetKeepsTheSavedOffsetWhenTheLookupFails(t *testing.T
if !got.Equal(saved) {
t.Fatalf("resolved %v, want %v", got, saved)
}
// remote.unmount recreates the directory, then saves the offset in the same
// second: starting at the creation second would replay the unmount's purge
unmounted := &filer_pb.Entry{Name: "x", Attributes: &filer_pb.FuseAttributes{Crtime: saved.Unix()}}
got, err = resolveLastSyncOffset("/buckets/x", 0, func() (*filer_pb.Entry, error) { return unmounted, nil }, savedOffset)
if err != nil {
t.Fatal(err)
}
if !got.Equal(saved) {
t.Fatalf("resolved %v, want the saved offset %v", got, saved)
}
}
func TestResolveLastSyncOffsetReturnsTheErrorToTheRetryLoop(t *testing.T) {