carlos / platform Public

host: the offline seal test flags a recopy only of an object still unchanged

TestOfflineStageThenStartThenSealSkipsThePreCopy failed with "the seal
recopied 0009/0000000000000001-0000000000000002.ltx, which the stage had
copied". It compared the stage's copy with the replica as it was at the
stage, not as it was at the seal. Litestream rewrites that snapshot under
the same key and size with new bytes (a new header timestamp) when its
compaction runs again, so whenever the rewrite landed between stage and
seal the seal rightly copied it again (ETag before c1b7ee8b..., at the seal
f32bb00a..., same 961 bytes). The recopy check now also requires the
object unchanged in the replica at the seal, as the kept count already
did.

It failed here without load too: 3 of 9 runs (-cpu 1,4,16). Under load
(2 cores, 8 busy loops, nice 19, -cpu 1,2,4): before 60 failures in 90,
after 0 in 150, every run still showing pre-copied objects skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev a59012c485a3fb8dbcad81657f8b06f73da89007 parent c11af5e
1 file changed, +10 −2
  • internal/host/movesoffline_stage_test.go +10 −2

CI passed — run details

diff --git a/internal/host/movesoffline_stage_test.go b/internal/host/movesoffline_stage_test.go
index 047efc554..649e72854 100644
--- a/internal/host/movesoffline_stage_test.go
+++ b/internal/host/movesoffline_stage_test.go
@@ -237,7 +237,8 @@ func TestOfflineStageThenStartThenSealSkipsThePreCopy(t *testing.T) {
// object the stage copied is still in the replica, unchanged, and the
// seal copied none of those (the loop below).
kept := 0
- for rel, o := range sw.replicaRel() {
+ atSeal := sw.replicaRel()
+ for rel, o := range atSeal {
if s, ok := preStaged[rel]; ok && s.Size == o.Size && preReplica[rel].ETag == o.ETag {
kept++
}
@@ -246,11 +247,18 @@ func TestOfflineStageThenStartThenSealSkipsThePreCopy(t *testing.T) {
t.Fatal("fixture: no pre-copied object survived to the seal, so nothing shows a skip")
}
t.Logf("the seal copied %d of %d objects; %d were pre-copied and skipped", len(sealCopies), len(sw.replicaRel()), kept)
+ // A recopy is wrong only for an object the replica still holds as the
+ // stage copied it. Litestream rewrites a snapshot under the same key
+ // (0009/<range>.ltx, same size, a new header timestamp) when its
+ // compaction runs again, and then the seal must copy it: comparing
+ // against the replica as it was at the stage alone failed whenever that
+ // rewrite landed in between (here at -cpu 4 without load, 3 of 9).
for _, k := range sealCopies {
rel := strings.TrimPrefix(k, sealPrefix+"/"+offHost+"/")
s, staged := preStaged[rel]
o, listed := preReplica[rel]
- if staged && listed && s.Size == o.Size && s.ETag == o.ETag {
+ now, still := atSeal[rel]
+ if staged && listed && still && s.Size == o.Size && s.ETag == o.ETag && now.ETag == o.ETag && now.Size == o.Size {
t.Fatalf("the seal recopied %s, which the stage had copied", rel)
}
}