fix(storage): an own batch's chunks stay cut candidates

Hydrated chunks are clean-filled, so the mark filter dropped the chunks
an own batch re-uploads under this layer's key, and the batch owned
none. The filter now keeps a chunk the current own batch picked.

The replay census keys functions by receiver-free name without
overwrites: two functions of one name on different types made it
flaky. The session-site census follows Put into PutPaced. The row
names the own-batch exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-28 11:49:44 -08:00
1 parent bab27a8282
commit 071b47c05f
4 files changed
+13 -10

No files matched your search

@@ -29,7 +29,7 @@ func TestLayoutRemoteSessionFieldSites(t *testing.T) {
}
// Begin returns the session it opened; CASHead's third read checks that
// it survived a concurrent operator HEAD write before retrying.
if !reflect.DeepEqual(fields, map[string]int{"openSessionLocked": 2, "rollBackLocked": 1, "Begin": 1, "Put": 1, "CASHead": 3, "CommitPendingSnapshot": 2, "writeRootLocked": 1, "Clean": 1, "syncSessionLocked": 3, "takeAbandonLocked": 1}) {
if !reflect.DeepEqual(fields, map[string]int{"openSessionLocked": 2, "rollBackLocked": 1, "Begin": 1, "PutPaced": 1, "CASHead": 3, "CommitPendingSnapshot": 2, "writeRootLocked": 1, "Clean": 1, "syncSessionLocked": 3, "takeAbandonLocked": 1}) {
t.Fatal("session field sites changed; enumerate and probe them", fields)
}
}
+3 -2
View File
@@ -896,9 +896,10 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
// A chunk known to hold HEAD's bytes at its current version (a clean
// fill, or a compare by a cut that did not publish) is not compared
// again, whatever returned it to the dirty set: any write since raises
// its version, and a newer HEAD changes its ref.
// its version, and a newer HEAD changes its ref. A chunk an own batch
// re-uploads under this layer's key stays: equal bytes are its point.
for idx := range candidates {
if m, ok := l.filledClean[idx]; ok && l.chunkVersion(idx) == m.version && l.head.Chunks[idx] == m.ref {
if m, ok := l.filledClean[idx]; ok && !l.own[idx] && l.chunkVersion(idx) == m.version && l.head.Chunks[idx] == m.ref {
delete(candidates, idx)
}
}
@@ -276,10 +276,11 @@ func replayCallersNoted(t *testing.T, srcs map[string]string) []string {
t.Helper()
type fnInfo struct {
file string
name string
defers bool
calls map[string]bool
}
fns := map[string]*fnInfo{}
var fns []*fnInfo // every function, also two of one name on different types
for file, src := range srcs {
f, err := parser.ParseFile(token.NewFileSet(), file, src, 0)
if err != nil {
@@ -290,7 +291,7 @@ func replayCallersNoted(t *testing.T, srcs map[string]string) []string {
if !ok || fn.Body == nil {
continue
}
info := &fnInfo{file: file, calls: map[string]bool{}}
info := &fnInfo{file: file, name: fn.Name.Name, calls: map[string]bool{}}
ast.Inspect(fn.Body, func(n ast.Node) bool {
if ds, ok := n.(*ast.DeferStmt); ok {
if sel, ok := ds.Call.Fun.(*ast.SelectorExpr); ok && sel.Sel.Name == "noteChunkRecovery" {
@@ -307,11 +308,12 @@ func replayCallersNoted(t *testing.T, srcs map[string]string) []string {
}
return true
})
fns[fn.Name.Name] = info
fns = append(fns, info)
}
}
var out []string
for name, info := range fns {
for _, info := range fns {
name := info.name
if !info.calls["replayRecordV3"] {
continue
}
@@ -321,9 +323,9 @@ func replayCallersNoted(t *testing.T, srcs map[string]string) []string {
} else {
var callers []string
all := true
for cname, c := range fns {
for _, c := range fns {
if c.calls[name] {
callers = append(callers, cname)
callers = append(callers, c.name)
all = all && c.defers
}
}
+1 -1
View File
@@ -574,7 +574,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
| `INV-WAL-V3-FLUSH-PROFILE-001` | Native flusher header/full-record/decode counters describe actual reads and validation; I/O failure is distinct from validation failure and only successfully materialized blocks count validated. | M1 checkpoint instrumentation | `walstore_v3.go` `readWholeRecordProfiledV3`, `readDirtyRecordV3` | `TestFlusherV3ProfileCountsRealRecordStages` | Observability; no durability transition change | ACTIVE |
| `INV-WAL-V3-WRITE-AHEAD-001` | No extent byte reaches the disk before its WAL record is durable: the flusher writes an extent only from dirty entries at or below the synced (acknowledged) WAL frontier; Recover and the install log fsync their records before raising it. | M1 Serving (flusher extent write) | `core/storage/flusher.go` `flushOnceInternal`; `walstore_v3.go` `recoverV3` (descriptor publish fsync before `wack`); `install_log_v3.go` | `TestRedCrashKeepingAnUnsyncedExtentWriteLeavesLocalAndHEADApart` (`core/storage/chunk_u1_reorder_test.go`); `TestFlusherWriteAheadNeverFlushingGuestReachesExtentAtPressure` (`core/storage/flusher_write_ahead_test.go`) | A checkpoint may pass a synced record superseded by an unsynced newer one only because the cycle's sync covers the whole file, WAL included (one file, one descriptor: `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`); separating WAL and extent, or a range sync, must first change the checkpoint bound | ACTIVE |
| `INV-WAL-V3-CAPTURE-CANDIDATES-001` | A retained WAL entry already covered by HEAD is not dirt since HEAD. New post-HEAD WAL entries, UNKNOWN map chunks and map max-LSN above HEAD remain capture candidates; an UNKNOWN chunk a fill wrote wholly from HEAD, with no local block and no mutation since, is not. | M5 candidate selection | `chunk_layer.go` `captureCandidates`, `fillOnce` | `TestChunkLayerV3CapturedUncheckpointedWALIsCleanUntilRewritten`, `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites`, `TestFreshFromHeadReadBackLeavesNoCutCandidates`, `TestFreshFromHeadFilledThenWrittenIsACandidate`, `TestEveryLocalWriteAfterACleanFillMakesTheChunkACandidate`, `TestABaseInstallAfterCleanFillsEndsTheirRecords`, `TestACleanFillRecordEndsWithItsHeadRef`, `TestARestoreTargetThatOnlyReadCutsNothing` | Conservative reachability unchanged; narrower redundant work | ACTIVE |
| `INV-WAL-V3-CAPTURE-COMPARED-001` | A chunk a cut compared equal to HEAD and did not publish is not compared again, whatever returned it to the candidates, while it has no mutation since and HEAD still names the ref it was compared with. | M5 candidate selection | `chunk_layer.go` `capture` | `TestARerunAfterAFailedCutComparesOnlyWhatDiffers`, `TestWithoutAFailedCutEveryUnknownChunkIsCompared`, `TestEveryDirtyMapInsertNotesTheChunkMutation` | Conservative reachability unchanged; narrower redundant work | ACTIVE |
| `INV-WAL-V3-CAPTURE-COMPARED-001` | A chunk a cut compared equal to HEAD and did not publish, or filled cleanly, is not compared again, whatever made it a candidate, while it has no mutation since and HEAD still names that ref; a chunk an own batch re-uploads stays a candidate. | M5 candidate selection | `chunk_layer.go` `capture` | `TestARerunAfterAFailedCutComparesOnlyWhatDiffers`, `TestWithoutAFailedCutEveryUnknownChunkIsCompared`, `TestEveryDirtyMapInsertNotesTheChunkMutation`, `TestOwnBatch_BoundedBatchesReplaceEveryForeignKey` | Conservative reachability unchanged; narrower redundant work | ACTIVE |
| `INV-WAL-V3-DESCRIPTOR-001` | A v3 descriptor slot is used only if it is valid: a matching CRC32C (Castagnoli), every reserved byte zero, an accepted impl, a nonzero slotGen at most 2^64-2, a nonzero nonce, and geometry consistent under checked arithmetic. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `decodeSlotV3`, `descriptorV3.validate`, `checkedAddV3` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3CounterExhaustion` (`core/storage/superblock_v3_test.go`) | — | STUB |
| `INV-WAL-V3-DESCRIPTOR-BASE-001` | A valid v3 descriptor slot has CheckpointLSN ≤ mapCoveredCheckpoint ≤ W, and BASE fields that follow the rules of its BASE state. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `descriptorV3.validate` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3InstalledMayHaveCursorBelowTail` (`core/storage/superblock_v3_test.go`) | — | STUB |
| `INV-WAL-V3-DESCRIPTOR-SELECT-001` | Of the two v3 descriptor slots, open selects the valid selectable slot with the higher slotGen, and never a prepared migration slot. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`); `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW` (`core/storage/walstore_close_v3_test.go`) | — | ACTIVE |