mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
s3: hold a stale-pointer repair while the live entry is still in grace
The heal checked the grace on the snapshot it took before the scan. A .versions entry stored again with the same pointer during the scan restarts the grace, so check it on the live entry the CAS is conditioned on before persisting the repair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5a65ebb42e
commit
2a2a70ebb1
2 files changed
+23
No files matched your search
@@ -2399,6 +2399,10 @@ func (s3a *S3ApiServer) healStaleLatestVersionPointer(bucket, normalizedObject s
|
||||
versioningHealInfof("abandoned", "bucket=%s key=%s mode=pointer_moved observed_id=%s live_id=%s", bucket, normalizedObject, observedId, liveId)
|
||||
return latestEntry, nil
|
||||
}
|
||||
if stalePointerFile != "" && versionPointerGraceLeft(liveEntry) > 0 {
|
||||
versioningHealInfof("deferred", "bucket=%s key=%s mode=recent_commit missing_file=%s", bucket, normalizedObject, stalePointerFile)
|
||||
return latestEntry, nil
|
||||
}
|
||||
|
||||
// Clone the live image before any mutation so the precondition compares
|
||||
// against exactly what the filer stores (nil and empty Extended maps are
|
||||
|
||||
@@ -177,3 +177,22 @@ func TestHealPointerlessVersionsEntryIgnoresRecentCommit(t *testing.T) {
|
||||
t.Errorf("repaired pointer = %q, want %q", got, presentId)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealStalePointerDefersWhenLiveEntryWasJustStored(t *testing.T) {
|
||||
old := time.Now().Add(-2 * staleVersionPointerGrace)
|
||||
pointerId := invertedVersionId(old)
|
||||
stored := committedAt(&filer_pb.Entry{Extended: map[string][]byte{
|
||||
s3_constants.ExtLatestVersionIdKey: []byte(pointerId),
|
||||
s3_constants.ExtLatestVersionFileNameKey: []byte("v_" + pointerId),
|
||||
}}, old)
|
||||
s3a, f := newHealPointerServer(t, stored, invertedVersionId(old.Add(-time.Hour)))
|
||||
snapshot := proto.Clone(stored).(*filer_pb.Entry)
|
||||
stored.CommitTsNs = time.Now().UnixNano()
|
||||
|
||||
if _, err := s3a.healStaleLatestVersionPointer("b", "k", snapshot, "v_"+pointerId); err != nil {
|
||||
t.Fatalf("healStaleLatestVersionPointer: %v", err)
|
||||
}
|
||||
if len(f.updates) != 0 {
|
||||
t.Fatalf("updates = %d, want the repair deferred for the pointer stored again", len(f.updates))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user