test: classify shared remover HEAD reads and absent metadata

This commit is contained in:
pingqiu committed 2026-11-28 18:26:34 -08:00
1 parent 494a094c62
commit 35b6ec7471
2 files changed
+15 -7

No files matched your search

@@ -38,7 +38,7 @@ var headReaders = map[string]string{
"core/host/volume/chunk_control.go ListSnapshots -> ReadHead": "refuses ErrHeadAbsent without creating HEAD (TestChunkControlUsesTheBoundLayoutIdentity)",
"core/frontend/chunkstore/layout/delete.go OperatorReleaseDependent -> ReadHead": "reads the source's HEAD (absent: refuses ErrHeadAbsent) and the target's: a target without HEAD (never created, or a restore that died between its VOLUME and its HEAD) gets a deleted HEAD written exclusively before the release (probe LayoutOperatorRelease)",
"core/frontend/chunkstore/layout/start.go Start -> ReadHead": "refuses ErrHeadAbsent and creates nothing (probe LayoutStart)",
"core/frontend/chunkstore/layout/remove.go RemoveUnreachable -> ReadHead": "refuses ErrHeadAbsent and writes nothing to the objects (probe LayoutRemoval)",
"core/frontend/chunkstore/layout/remove.go removePlanned -> ReadHead": "refuses ErrHeadAbsent and writes nothing to chunks, roots or segments (probe LayoutRemoval)",
"core/frontend/chunkstore/layout/snapshots.go RunAddDependent -> ReadHead": "refuses ErrHeadAbsent before reading any root and writes nothing (probe LayoutAddDependent)",
"core/frontend/chunkstore/catalog_b.go DeleteVolume -> ReadHead": "refuses ErrHeadAbsent before any write (probe BCatalog)",
"core/frontend/chunkstore/catalog_b.go ReadHead -> ReadHead": "found=false to the caller, which reports no HEAD (probe BCatalog)",
@@ -237,6 +237,14 @@ func TestHeadReaders_AbsentHeadProbes(t *testing.T) {
if _, err := layout.RemoveUnreachable(ctx, &absentLayoutHead{}, r, pool, layout.HolderID{Epoch: 1, Holder: "h"}, "c", 0, []layout.ChunkName{layout.NameChunk(1, []byte("x"))}); !errors.Is(err, layout.ErrHeadAbsent) {
t.Fatalf("layout removal over an absent HEAD: %v; want ErrHeadAbsent", err)
}
for kind, name := range map[string]string{
layout.RootDir: (layout.RootName{Hash: layout.Sum([]byte("root"))}).String(),
layout.SegDir: (layout.SegName{Hash: layout.Sum([]byte("segment"))}).String(),
} {
if _, err := layout.NewCleaner(&absentLayoutHead{}, r, pool, layout.HolderID{Epoch: 1, Holder: "h"}, "c").Page(ctx, kind, 0, []string{name}); !errors.Is(err, layout.ErrHeadAbsent) {
t.Fatalf("%s removal over absent HEAD: %v", kind, err)
}
}
if pool.writes != 0 {
t.Fatalf("layout removal over an absent HEAD wrote %d times to the objects", pool.writes)
}
@@ -128,8 +128,8 @@ func owners(m map[string]bool) []string {
// - Release of a dependent: RunReleaseDependent is used only by
// DeleteVolume (its own HEAD is deleting) and OperatorReleaseDependent,
// which reads the target's HEAD before it releases.
// - Pool: a name starting with Delete or Remove is used only in
// RemoveUnreachable, whose only removal is DeleteMarked, each right
// - Objects: a name starting with Delete or Remove is used only in
// Cleaner.removePlanned, whose only removal is DeleteMarked, each right
// after a gate on its Mark's error, and in DeleteVolume, whose steps run
// in the delete's order: no holder, HEAD deleting, the dependents
// released, the objects deleted (conditional on the volume id), HEAD
@@ -227,7 +227,7 @@ func guardFindings(code map[string]map[string]bool, decl, tests map[string]bool)
}
// removerOrderFindings checks the removal rule (7') in the sources: in
// RemoveUnreachable the only removal call is DeleteMarked (a delete
// Cleaner.removePlanned the only removal call is DeleteMarked (a delete
// conditional on the remover's own mark), and each is IMMEDIATELY
// preceded, in the same block, by a mark gate: an if statement whose init
// calls Mark and whose body leaves on its error (return or continue). An
@@ -321,17 +321,17 @@ func removerOrderFindings(t *testing.T, srcs map[string]string) []string {
deletes++
for _, name := range names {
if name != "DeleteMarked" {
bad = append(bad, "RemoveUnreachable calls "+name+": its only removal is DeleteMarked, conditional on its own mark")
bad = append(bad, "Cleaner.removePlanned calls "+name+": its only removal is DeleteMarked, conditional on its own mark")
}
}
if i == 0 || !markGate(blk.List[i-1]) {
bad = append(bad, "RemoveUnreachable removes without a mark gate immediately before it (an if on Mark's error that leaves)")
bad = append(bad, "Cleaner.removePlanned removes without a mark gate immediately before it (an if on Mark's error that leaves)")
}
}
return true
})
if deletes == 0 {
bad = append(bad, "RemoveUnreachable is declared and has no delete: the scan is broken")
bad = append(bad, "Cleaner.removePlanned is declared and has no delete: the scan is broken")
}
}
}