From 44eea4ee49d48134ac0e52af5965901b4562b9c8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 14:54:00 -0800 Subject: [PATCH 1/7] fix: use native v3 WAL pressure for write admission --- .../durable/provider_chunk_burst_test.go | 81 +++++++++++++++++++ .../frontend/nvme/flush_error_log_test.go | 51 ++++++++++++ seaweed-block/core/frontend/nvme/session.go | 5 ++ seaweed-block/core/storage/walstore.go | 26 +++++- .../storage/walstore_admission_v3_test.go | 41 ++++++++++ seaweed-block/docs/design/invariants.md | 7 +- .../docs/design/wal-v3-burst-admission.md | 37 +++++++++ 7 files changed, 242 insertions(+), 6 deletions(-) create mode 100644 seaweed-block/core/frontend/durable/provider_chunk_burst_test.go create mode 100644 seaweed-block/core/frontend/nvme/flush_error_log_test.go create mode 100644 seaweed-block/core/storage/walstore_admission_v3_test.go create mode 100644 seaweed-block/docs/design/wal-v3-burst-admission.md diff --git a/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go b/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go new file mode 100644 index 0000000000..f47f9b5bbe --- /dev/null +++ b/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go @@ -0,0 +1,81 @@ +package durable_test + +import ( + "context" + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/frontend/nvme" + "github.com/seaweedfs/seaweed-block/core/storage" + "testing" + "time" +) + +// Public provider + actual NVMe handler, file-backed v3 with the default +// 64 MiB WAL. No injected I/O failures, private selector, or flusher control. +func TestWALStoreChunkV3_SequentialBurstFlush(t *testing.T) { + const total = 320 * 1024 * 1024 + const transfer = 128 * 1024 + const flushEvery = 48 * 1024 * 1024 + ctx := context.Background() + remote := storage.NewMemChunkRemote() + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), BlockSize: 4096, + NumBlocks: total / 4096, ChunkBlocks: 1024, + ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }, + }, v1View()) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := p.Close(); err != nil { + t.Logf("close: %v", err) + } + }) + s, err := p.EnsureStorage("v1") + if err != nil { + t.Fatal(err) + } + if _, err = p.RecoverVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + be, err := p.Open(ctx, "v1") + if err != nil { + t.Fatal(err) + } + h := nvme.NewIOHandler(nvme.HandlerConfig{Backend: be, BlockSize: 4096, VolumeSize: total}) + data := make([]byte, transfer) + start := time.Now() + for off := 0; off < total; off += transfer { + for i := range data { + data[i] = byte(off/transfer) + byte(i) + } + r := h.Handle(ctx, nvme.IOCommand{Opcode: 0x01, NSID: 1, SLBA: uint64(off / 4096), NLB: transfer / 4096, Data: data}) + if r.AsError() != nil { + _, syncErr := s.Sync() + t.Fatalf("write bytes=%d elapsed=%v result=%+v exact Sync=%T %v", off, time.Since(start), r, syncErr, syncErr) + } + if (off+transfer)%flushEvery == 0 || off+transfer == total { + r = h.Handle(ctx, nvme.IOCommand{Opcode: 0x00, NSID: 1}) + if r.AsError() != nil { + _, syncErr := s.Sync() + t.Fatalf("flush bytes=%d elapsed=%v result=%+v exact Sync=%T %v", off+transfer, time.Since(start), r, syncErr, syncErr) + } + t.Logf("flush bytes=%d elapsed=%v", off+transfer, time.Since(start)) + } + } + // The expected bytes come from the submitted pattern, not another reader. + for off := 0; off < total; off += transfer { + got, err := be.Read(ctx, uint64(off), transfer) + if err != nil { + t.Fatalf("readback at%d: %v", off, err) + } + if len(got) != transfer { + t.Fatalf("short readback at%d: %d", off, len(got)) + } + for i, b := range got { + if want := byte(off/transfer) + byte(i); b != want { + t.Fatalf("readback byte%d=%#x want%#x", off+i, b, want) + } + } + } + +} diff --git a/seaweed-block/core/frontend/nvme/flush_error_log_test.go b/seaweed-block/core/frontend/nvme/flush_error_log_test.go new file mode 100644 index 0000000000..a83c59a90b --- /dev/null +++ b/seaweed-block/core/frontend/nvme/flush_error_log_test.go @@ -0,0 +1,51 @@ +package nvme + +import ( + "bytes" + "context" + "errors" + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "log" + "strings" + "testing" +) + +type flushErrorBackend struct { + frontend.Backend + syncErr error +} + +func (b *flushErrorBackend) Sync(context.Context) error { return b.syncErr } + +func TestSessionFlushLogsBackendReason(t *testing.T) { + var logs bytes.Buffer + b := &flushErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1"}), syncErr: errors.New("injected Sync failure: extent EIO")} + s := &Session{handler: NewIOHandler(HandlerConfig{Backend: b}), logger: log.New(&logs, "", 0), qid: 7, respCh: make(chan *response, 1), done: make(chan struct{})} + req := &Request{} + req.capsule.OpCode = ioFlush + req.capsule.NSID = 1 + s.dispatchIO(context.Background(), req) + resp := <-s.respCh + if resp.resp.Status != MakeStatusField(SCTGeneric, SCInternalError, true) { + t.Fatalf("status=%#x", resp.resp.Status) + } + for _, want := range []string{"Flush failed", "qid=7", "nsid=1", "backend error on flush: injected Sync failure: extent EIO"} { + if !strings.Contains(logs.String(), want) { + t.Fatalf("log %q missing %q", logs.String(), want) + } + } + if strings.Count(logs.String(), "Flush failed") != 1 { + t.Fatalf("duplicate failure log: %q", logs.String()) + } + logs.Reset() + b.syncErr = nil + s.dispatchIO(context.Background(), &Request{capsule: req.capsule}) + resp = <-s.respCh + if resp.resp.Status != 0 { + t.Fatalf("success status=%#x", resp.resp.Status) + } + if logs.Len() != 0 { + t.Fatalf("successful Flush logged a failure: %q", logs.String()) + } +} diff --git a/seaweed-block/core/frontend/nvme/session.go b/seaweed-block/core/frontend/nvme/session.go index 6578770090..31d9e5d4e0 100644 --- a/seaweed-block/core/frontend/nvme/session.go +++ b/seaweed-block/core/frontend/nvme/session.go @@ -470,6 +470,11 @@ func (s *Session) dispatchIO(ctx context.Context, req *Request) { NSID: req.capsule.NSID, }) if res.AsError() != nil { + // CQEs carry status, not the backend's diagnostic. Keep the reason + // at the real session boundary so host fsync EIO can be attributed. + if s.logger != nil { + s.logger.Printf("nvme: Flush failed qid=%d nsid=%d sct=%#x sc=%#x reason=%s", s.qid, req.capsule.NSID, res.SCT, res.SC, res.Reason) + } req.resp.Status = MakeStatusField(res.SCT, res.SC, true) } s.enqueueResponse(&response{resp: req.resp}) diff --git a/seaweed-block/core/storage/walstore.go b/seaweed-block/core/storage/walstore.go index 6c804f1d8b..0f1d045aa9 100644 --- a/seaweed-block/core/storage/walstore.go +++ b/seaweed-block/core/storage/walstore.go @@ -383,9 +383,7 @@ func openInitializedInternal(path string, f *os.File, sb *superblock, metadata B MaxConcurrent: 64, SoftWatermark: 0.70, HardWatermark: 0.90, - WALUsedFn: func() float64 { - return s.wal.usedFraction() - }, + WALUsedFn: s.walUsedFraction, NotifyFn: func() { if s.flusher != nil { s.flusher.NotifyUrgent() @@ -401,6 +399,28 @@ func openInitializedInternal(path string, f *os.File, sb *superblock, metadata B return s, nil } +// walUsedFraction samples the active format's writer. The legacy writer is +// still present on a v3 store but receives no appends, so its occupancy is zero. +// Store admission is held only for this snapshot, never across a pressure wait. +func (s *WALStore) walUsedFraction() float64 { + s.mu.RLock() + defer s.mu.RUnlock() + if s.v3 == nil { + return s.wal.usedFraction() + } + w := s.v3.w + if w == nil { + return 1 + } // recovery/reset has not admitted a writer yet + d, floor, valid := s.v3.pub.walSnapshotV3() + w.mu.Lock() + defer w.mu.Unlock() + if !valid || d.WALSize == 0 || d.Nonce != w.nonce || w.head < floor { + return 1 // uncertain space is not admission headroom + } + return float64(w.head-floor) / float64(d.WALSize) +} + func retainedLSNFromCheckpoint(checkpointLSN uint64) uint64 { if checkpointLSN == 0 { return 0 diff --git a/seaweed-block/core/storage/walstore_admission_v3_test.go b/seaweed-block/core/storage/walstore_admission_v3_test.go new file mode 100644 index 0000000000..d357907be7 --- /dev/null +++ b/seaweed-block/core/storage/walstore_admission_v3_test.go @@ -0,0 +1,41 @@ +package storage + +import ( + "path/filepath" + "testing" +) + +func TestWALStoreV3AdmissionUsesNativeOccupancy(t *testing.T) { + s, err := CreateWALStore(filepath.Join(t.TempDir(), "volume"), 256, 4096) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = s.Close() }) + s.DisableAutoFlushForRecoveryTest() + if s.v3 == nil { + t.Fatal("public selector did not create v3") + } + if got := s.admission.walUsed(); got != 0 { + t.Fatalf("initial occupancy=%g", got) + } + blocks := make([][]byte, 32) + for i := range blocks { + blocks[i] = blk(byte(i)) + } + if _, err := s.WriteBatch(0, blocks); err != nil { + t.Fatal(err) + } + want := float64(32*4096+70) / float64(64*1024*1024) + if got := s.admission.walUsed(); got != want { + t.Fatalf("native occupancy=%g want%g; legacy=%g", got, want, s.wal.usedFraction()) + } + if _, err := s.Sync(); err != nil { + t.Fatal(err) + } + if err := s.flusher.flushOnce(); err != nil { + t.Fatal(err) + } + if got := s.admission.walUsed(); got != 0 { + t.Fatalf("both-slot-released occupancy=%g", got) + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 401f3891d0..fb5ee16c75 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -57,7 +57,7 @@ stateDiagram-v2 | Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001` | | Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` holds the capture barrier and invalidates proofs at start/end (legacy LSN scan remains fixture-only) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001` | | Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001` | -| Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001` | +| Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; write admission samples the active writer's native pressure before waiting; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001`, `INV-WAL-V3-ADMISSION-001` | | Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse (C11 bitmap/superblock path remains legacy-fixture-only) | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001` | | Serving | FaultLatched | the first failed `fsync` of the store file, or a WAL append whose write failed | `core/storage/walstore.go` `noteFsyncFailure`, `noteAppendFailure`, `syncFile` | `INV-WAL-FSYNC-STICKY-001`, `INV-WAL-APPEND-STICKY-001` | | FaultLatched | FaultLatched | every later `Sync`, write, checkpoint and `Recover` on the same open store is refused | `core/storage/walstore.go` `stickyIOFault` | `INV-WAL-FSYNC-STICKY-001` | @@ -286,6 +286,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-DESCRIPTOR-001` | A v3 descriptor slot is used only if it is valid. It needs a matching CRC32C (Castagnoli), every reserved byte zero, an accepted impl, a nonzero slotGen at most 2^64-2 and a nonzero nonce. Its geometry must be consistent with checked arithmetic, its BASE fields must follow their per-state rules, and CheckpointLSN ≤ mapCoveredCheckpoint ≤ W must hold. Of the two slots, the valid selectable one with the higher slotGen wins. A prepared migration slot is never selected. Equal generations with different bytes, or slots that disagree on identity or geometry, are refused. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `decodeSlotV3`, `selectSlotV3`, `nextSlotGenV3` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3Selection`, `TestSlotV3CounterExhaustion`, `TestSlotV3InstalledMayHaveCursorBelowTail` (`core/storage/superblock_v3_test.go`) | — | STUB | | `INV-WAL-V3-RECORD-001` | An impl-3 record codec uses the fixed 62-byte prefix and 70-byte overhead, CRC32C and an explicit EntrySize. It refuses unknown types/flags, a zero nonce, invalid per-type geometry, overflowing count/LSN/cursor or LBA spans, nonzero padding, bad CRC/footer and truncation before allocating a payload. Codec success alone is not nonce/cursor/lap replay admission. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `payloadSizeV3`, `encodeWALEntryV3`, `decodeWALEntryV3` | `TestWALEntryV3_CanonicalBarrierBytes`, `TestWALEntryV3_TypeFootprints`, `TestWALEntryV3_RefusesInvalidEncode`, `TestWALEntryV3_RefusesMalformedWire`, `FuzzWALEntryV3_DecodeNeverPanics` | `WALRecovery` abstract record validity; physical byte rules are code-test obligations | STUB | | `INV-WAL-V3-LSN-ORDER-001` | A v3 writer accepts only a first LSN above its highest consumed LSN; a batch consumes its whole validated range. Equal/lower requests return ErrWALLSNOrder before any pwrite or cursor change. Constructor coverage and a recovered kept frontier count as consumed; a fenced-away suffix does not. | M1 v3 append | `core/storage/wal_io_v3.go` `append`, `newWALWriterV3`, `restoreScanV3` | `TestWALLSNOrderV3_RefusesDuplicateAndLower`, `TestWALLSNOrderV3_BatchConsumesFullRange`, `TestWALLSNOrderV3_RestoreUsesKeptNotDroppedFrontier`, `TestWALLSNOrderV3_DescriptorFloorIsAlreadyConsumed`, `TestWALIOV3_ValidatedFrontierIntervals`, `TestWALIOV3_ConcurrentAppendsHaveUniqueCursors` | Physical LSN-strict prefix is a contract constraint; r16 model correspondence is pending | STUB | +| `INV-WAL-V3-ADMISSION-001` | Native v3 WAL pressure uses its physical writer head minus the both-slot reuse floor, never the inactive legacy writer. Existing soft/hard waits wake the flusher without holding store, descriptor or writer locks. No wait grants reuse or acknowledges writes. | M1 Serving (write admission) | `walstore.go` `walUsedFraction`, `openInitializedInternal`; `wal_admission.go` `Acquire` | `TestWALStoreV3AdmissionUsesNativeOccupancy`; `TestWALStoreChunkV3_SequentialBurstFlush` (public provider and NVMe handler, default 64 MiB WAL, 320 MiB literal readback) | Existing reuse/durability rules unchanged; pressure/liveness is not a new model claim | ACTIVE | | `INV-WAL-V3-RECLAIM-001` | A mapped v3 checkpoint releases only complete validated record ends covered by the checkpoint and outside the retention window; an installing BASE retains its install suffix. Physical recovery rebuilds the volatile boundary index only from the trusted kept scan, without restoring a disconnect cursor. Tail/head/map/checkpoint/W publish together, followed by metadata-only rollover; both slot tails still pin reuse. Failure grants no reuse and retains exact dirty retry identity. Checkpoint publication excludes writer admission through both-slot rollover and dirty-reference retirement. Idle, unchanged-checkpoint and admission settle pending rollover; catch-up revalidates tail/checkpoint before delivering its buffered scan. | M1 checkpoint / existing two-slot retirement | `wal_io_v3.go` `reclaimThroughV3`, `rememberReclaimScanV3`; `walstore_map_checkpoint_v3.go` `publishCheckpointV3`; `descriptor_v3.go` `rolloverIfPinned` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin`, `TestWALStoreV3ReclaimRetiresReferencesBeforeReuse`, `TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint`, tagged `TestCatchUpV3AfterCheckpointRingReuse`, `TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled` | Existing dual-slot retirement and nonce/cursor contract; concrete index/recovery/caller wiring is a code-test obligation | STUB | | `INV-WAL-V3-OWNER-001` | v3 read/write open, offline readonly open and migrate-v3 acquire the same exclusive nonblocking OS file lock before reading slots or changing bytes. Contention refuses with volume locked; descriptor close releases it, allowing retry. | M1 open admission / offline migration precondition | `core/storage/volume_lock*.go`; `walstore_v3.go`; `walstore_readonly_v3.go`; `cmd/sw-block/migrate.go` | `TestMigrateV3RefusesAnOpenV3Volume`, `TestMigrateV3ExcludesOpenUntilCommitFinishes` (tag `swblock_format_v3_test`), `TestWALStoreV3CreatorKeepsOwnershipThroughPublication`, `TestWALStoreV3OwnerExcludesOpenAndReadOnly` | OS mutual exclusion is a caller obligation, outside the abstract crash model; existing open states unchanged | STUB | | `INV-WAL-V3-CATCHUP-001` | A dark v3 catch-up source refuses while installing, including an empty at-head request. Requests covered by an installed BASE require rebuild (typed WALRecycled); damage in retained WAL remains an integrity failure. Before emitting any entries the scan revalidates recovery generation, nonce, BASE state/ID and install epoch, so begin/complete/retire ABA cannot publish a superseded prefix. | M1 BASE lifecycle / M3 CatchingUp (dark callers) | `core/storage/walstore_recovery.go` `ScanLBAs`, `scanLBAsV3`, `v3CatchUpEntries` | `TestCatchUpV3InstallingAtHeadRefuses`, `TestCatchUpV3CompletedBASEUsesRebuild`, `TestCatchUpV3InstallRetireABARefusesOldScan`, `TestCatchUpV3CorruptFirstRecordFails`, `TestCatchUpV3CorruptMiddleRecordFails`, `TestCatchUpV3CompletedBASESuffix` (tag `swblock_format_v3_test`, actual catch-up sender) | Existing BASE and catch-up transitions unchanged; this physical scan/source-lifetime obligation is covered by deterministic caller tests | STUB | @@ -302,7 +303,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-BATCH-001` | A v3 `WriteBatch` of n blocks is one multi-block record (type 0x04) with LSNs first..first+n-1 and one CRC32C, so a crash keeps all of it or none; the writer consumes the whole LSN range, so the next write continues after it. Each block's dirty entry names its data offset inside the record, and every reader (the store read, the flusher, recovery's replay, the install-path replays and the dark offline reader) validates the whole record and the block's LBA, LSN and offset in it. A torn unacknowledged batch is dropped whole; a torn acknowledged one fails closed; a failed batch pwrite latches the store and is never acknowledged. The map coverage follows every block's LSN. | M1 Serving (dark) | `core/storage/walstore_v3.go` `writeBatchV3Locked`, `replayRecordV3`, `readWholeRecordV3`, `blockOfRecordV3`, `flusher.readDirtyRecordV3`; `core/storage/walstore.go` `WriteBatch`; `core/storage/walstore_readonly_v3.go` | `TestWALStoreV3BatchRoundTripAcrossACrash`, `TestWALStoreV3TornBatchIsAllOrNothing`, `TestWALStoreV3CrashMidBatchServesNoneOfIt`, `TestWALStoreV3BatchAckCoversItsLastLSN`, `TestWALStoreV3BatchFlushesEveryBlock`, `TestWALStoreV3ReadOnlyReaderServesBatchBlocks`, `TestWALStoreV3BatchRecordsMapCoverage` (`core/storage/walstore_batch_v3_test.go`) | `WALFormat` batch records (claude05) | STUB | | `INV-WAL-V3-MIGRATE-001` | `sw-block migrate-v3` rewrites only the descriptor of a cleanly closed v2/impl1 volume whose WAL the exhaustive scan proves flushed; the scan and the geometry check run before any write, and a refusal leaves the volume and every sidecar byte-identical. It keeps the extent base (WALSize = old - 4096), writes an atomic operator backup, an all-UNKNOWN initial map (covered = the v2 checkpoint), the prepared slot B, slot A at phase 0 (the commit point), slot B at phase 0, and only then retires the v2 chunk bitmap; each step is durable before the next. A rerun decides from the slot bytes alone: before the commit it restarts with a full rescan; after it, it only finishes the rollover and the retirement; a prepared B with an invalid A refuses with `ErrMigrationIncomplete`, as v3 open does; it never reads or restores the backup. | offline tool | `cmd/sw-block/migrate.go`; `cmd/sw-block/internal/v2legacy`; `core/storage/migrate_v3.go` | `TestMigrateV3CleanVolume`, `TestMigrateV3RefusalsChangeNothing`, `TestMigrateV3CrashAfterEachStepIsResumable`, `TestMigrateV3OldBinaryAfterPreparation`, `TestMigrateV3OldWALOverwritesThePreparedSlot`, `TestMigrateV3NeverRestoresTheBackup` (`cmd/sw-block/migrate_test.go`); tagged `TestMigrateV3VolumeOpensAsV3`, `TestMigrateV3PreparedOnlyRefusedByV3Open` | none (tool) | STUB | | `INV-FE-FUA-SYNC-001` | A FUA write completes only after `Sync` succeeds. | M1 Serving (frontend) | `core/frontend/nvme/io.go` `IOHandler.write`; `core/frontend/ublk/dispatch.go` `handler.serve` | `TestNVMeWriteFUACompletion` (`core/frontend/nvme/fua_test.go`); `TestDispatch_WriteFUASyncsBeforeCompleting` (`core/frontend/ublk/dispatch_test.go`) | — | ACTIVE | -| `INV-FE-FLUSH-SYNC-001` | A flush is a `Sync` of the backend, and a failed `Sync` fails the command instead of acknowledging it. | M1 Serving (frontend) | `core/frontend/nvme/io.go` `IOHandler.Handle`; `core/frontend/ublk/dispatch.go` `handler.serve` | `TestT3b_NVMe_Flush_DispatchesToBackend` (`core/frontend/nvme/t3b_flush_test.go`); `TestDispatch_FlushSyncs`, `TestDispatch_BackendFailuresAreReportedNotAcknowledged` (`core/frontend/ublk/dispatch_test.go`) | — | ACTIVE | +| `INV-FE-FLUSH-SYNC-001` | A flush is a `Sync` of the backend, and a failed `Sync` fails the command instead of acknowledging it. The NVMe session records its mapped status and backend reason in the target log. | M1 Serving (frontend) | `core/frontend/nvme/io.go` `IOHandler.Handle`; `core/frontend/ublk/dispatch.go` `handler.serve` | `TestT3b_NVMe_Flush_DispatchesToBackend` (`core/frontend/nvme/t3b_flush_test.go`); `TestSessionFlushLogsBackendReason` (`core/frontend/nvme/flush_error_log_test.go`); `TestDispatch_FlushSyncs`, `TestDispatch_BackendFailuresAreReportedNotAcknowledged` (`core/frontend/ublk/dispatch_test.go`) | — | ACTIVE | | `INV-FE-LINEAGE-GATE-001` | Every `Read`, `Write` and `Sync` re-checks `{volume, replica, epoch, endpoint version}` and health against the current projection; any drift returns `ErrStalePrimary`. The volume-ID comparison is code reading: no cited test varies the volume ID. | M3 Primary → Supporting \| Excluded (I/O side) | `core/frontend/durable/storage_adapter.go` `gate`, `lineageCheck` | `TestT3a_StorageBackend_FenceCheck_Epoch`, `TestT3a_StorageBackend_FenceCheck_EV`, `TestT3a_StorageBackend_FenceCheck_Replica`, `TestT3a_StorageBackend_FenceCheck_Healthy` (`core/frontend/durable/storage_adapter_test.go`); `TestG8A_SupersedeFact_FencesOldPrimaryDurableBackend` (`core/host/volume/g8a_stale_fence_test.go`) | — | ACTIVE | Notes: @@ -315,7 +316,7 @@ Notes: - `INV-WAL-V3-MAP-BYTES-001`: row 6 prepares durable pinned tuples only. Root/merged-descriptor coverage, mutation proofs and real chunk/provider replacement are row 7; no serving or checkpoint advance is authorized by the codec/store. No sidecar page reclamation is implemented, so fallback or uncertain generations remain pinned conservatively. - `INV-WAL-CHECKPOINT-SNAPSHOT-001`: The SIGKILL test is Linux only. -- `INV-FE-FLUSH-SYNC-001`: The failed-`Sync` case is asserted for ublk; for NVMe/TCP only the dispatch to `Sync` is asserted here. +- `INV-FE-FLUSH-SYNC-001`: NVMe/TCP also asserts failed-Sync status and reason logging through the actual session dispatch, and success produces no failure log. - `INV-WAL-V3-RESET-001`: Format bump v3, plan row 8 (DESIGN 8.6). Dark: no production path calls the reset, and it must not be activated before the reset model (r4.5) passes. No v3 tail release exists yet, so the precondition is CheckpointLSN >= W rather than an empty retained range: retained old-incarnation bytes at or below the checkpoint are preserved in the extent. The map root is unchanged by a reset, so no map page is retired. - `INV-WAL-V3-BASE-001`: Format bump v3, plan row 9a (DESIGN r17.3.1 sections 8.1, 8.2, 8.4, 8.5, 8.7). Dark: only tests reach it. Row 9b makes the seam `BaseInstallPreparer.BeginBaseInstall(baseLSN, installID) (InstallHandle, error)`: the dual-lane `Receiver` begins at SessionStart (BaseLSN = FromLSN, a fresh random ID) and its `RebuildSession` writes, applies and completes only through the handle, propagating the `MarkBaseComplete` error; stores without the seam keep their exact pre-seam behaviour through the lazy legacy handle (parallelwal's staging is now `BaseStager.BeginBaseStage`). Since row 10b the legacy single-lane caller (`core/transport/replica.go`) is on the handle too: the first admitted `MsgRebuildBlock` (or an empty rebuild's `MsgRebuildDone`) begins one install per connection at the lineage's frontier hint under a fresh random ID, blocks go through `WriteBase`, a different hint on the connection is refused, and done completes and then Syncs, closing the connection with no `MsgBarrierResp` when either fails; a reconnect is a superseding install under the coverage rule (tagged controls in `core/transport/replica_install_format_v3_test.go`). Until the chunk layer's side of the v3 install protocol lands (codex03), a v3 begin with an attached chunk layer is refused (`errV3NotYet`), writing nothing; since row 9c the v3 `SeedChunkFrontier` publishes CheckpointLSN = W = map coverage = lsn through the one checkpoint publication (`publishCheckpointV3`: data fsync, metadata and chunk barriers, owned-map candidate, the sole slot publisher under syncMu with the lifetime check), moves the volatile frontier only after it, publishes nothing on failure, and refuses local writes, an install, an attached layer or a store without an owned map; a HEAD restore onto a dark v3 store still refuses in the provider (`errV3RestoreNotYet`) until codex03's v3 FreshFromHead restore lands; since row 11a an installing physical reopen (an installing ID this open did not begin) keeps its recovered bounds (E, R, intact or damaged) without fencing, publishing or admitting; a same-open Recover of this open's live install records none, so its still-valid handle cannot append past a cached cut that a resume would fence from (codex01 row 11b P1); it republishes the live install's trusted records in the dirty map and keeps the volatile map coverage, or latches the store when the recovered cut is short of the live writer, and a covering superseding begin after it fences [E, floor + WALSize) and fsyncs before its two-slot installing publication, anchors at P = max(E, the persisted retainedHead) without lowering retainedHead, and restarts the writer at P (forward only); since row 11b the same-ID resume after a reopen (store level; no current caller resumes, both receivers begin fresh IDs) runs under `installMu` exclusive and appends nothing until the trusted-through-W check (intact suffix and E >= the persisted retainedHead), the fence of [E, floor + WALSize) with fsync and a retainedHead = E publication all held, refusing with `ErrInstallSuffixDamaged` and writing nothing otherwise; the writer continues at E and the recovered install-lane records are replayed. A begin while installed is refused until retirement (8.5 has no installed -> installing edge). - `INV-WAL-V3-MIGRATE-001`: Format bump v3, plan rows 13a and 13b (DESIGN 10.1). Not yet in this row: the exclusive advisory lock that v3 open will share (precondition 1; it lands with the 12b open path), and raw v2 fixtures committed under testdata (today's controls build v2 volumes with the v2 code that row 14 deletes). The minimum migrated WAL size (64 KiB and two single-block records) is provisional. diff --git a/seaweed-block/docs/design/wal-v3-burst-admission.md b/seaweed-block/docs/design/wal-v3-burst-admission.md new file mode 100644 index 0000000000..1dc11b2da5 --- /dev/null +++ b/seaweed-block/docs/design/wal-v3-burst-admission.md @@ -0,0 +1,37 @@ +# Native WAL burst admission + +A fresh v3 walstore-chunk volume has a 64 MiB WAL by default. Before this fix, +the common admission callback sampled `s.wal`, the legacy writer. V3 appends go +to `s.v3.w`, so the inactive legacy occupancy stayed zero. A real provider and +NVMe handler writing 128 KiB requests with Flush every 48 MiB hit WRITE +InternalError / WAL region full at 66,977,792 submitted bytes. The same schedule +reproduced on root WSL and non-root tp04. The preceding Flush and a direct Sync +after the failed Write succeeded. This does not establish the cause of the +reported guest SyncAll EIO; a host fsync error is not by itself an observed +backend Sync error. + +Admission now samples native physical head minus the both-slot reuse floor. +The existing soft/hard watermarks, flusher notification and deadline stay in +place. The sampler holds store.mu shared while selecting the writer, snapshots +the descriptor/floor, releases descMu, then samples head under writer.mu. It +releases all these locks before admission can sleep or wait. Existing publication +order is unchanged; there is no fsync, slot/map write, early acknowledgement or +new reuse permission in this callback. A missing/unbound writer reports full. +Legacy fixtures keep the original legacy occupancy. Very large batches, +concurrent already-admitted requests or a fully unsynced ring can still exhaust +space; this change is not a reservation scheme or a guarantee for every burst. + +The real NVMe session logs failed Flush status and IOResult.Reason using its +existing target logger. This preserves the backend diagnostic that the CQE +cannot carry. Success emits no failure log; the status/error mapping is +unchanged. Use that target log to attribute a future Flush failure rather than +inferring its cause from a guest EIO alone. + +Controls: `TestWALStoreV3AdmissionUsesNativeOccupancy` asserts exact encoded +occupancy and release after checkpoint/rollover; the public provider + actual +NVMe handler `TestWALStoreChunkV3_SequentialBurstFlush` writes 320 MiB and verifies +every byte against submitted literals; `TestSessionFlushLogsBackendReason` +uses actual session dispatch, asserts error status, reason logging exactly once, +and no failure log on success. INV-WAL-V3-ADMISSION-001 and +INV-FE-FLUSH-SYNC-001 record these checks. The durability/format model is unchanged; +no new TLC or mounted performance claim is made. From 1534404f7f3eb7a6f5d82344240a140bfdd46f7b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 14:55:12 -0800 Subject: [PATCH 2/7] test: use backend buffer read contract in burst oracle --- .../core/frontend/durable/provider_chunk_burst_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go b/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go index f47f9b5bbe..ff549a8da1 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go +++ b/seaweed-block/core/frontend/durable/provider_chunk_burst_test.go @@ -64,12 +64,13 @@ func TestWALStoreChunkV3_SequentialBurstFlush(t *testing.T) { } // The expected bytes come from the submitted pattern, not another reader. for off := 0; off < total; off += transfer { - got, err := be.Read(ctx, uint64(off), transfer) + got := make([]byte, transfer) + n, err := be.Read(ctx, int64(off), got) if err != nil { t.Fatalf("readback at%d: %v", off, err) } - if len(got) != transfer { - t.Fatalf("short readback at%d: %d", off, len(got)) + if n != transfer { + t.Fatalf("short readback at%d: %d", off, n) } for i, b := range got { if want := byte(off/transfer) + byte(i); b != want { From 8529530c4b48a099b17a6158f3830d2060339d49 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 15:15:15 -0800 Subject: [PATCH 3/7] fix: preserve binding refusals before capacity waits --- seaweed-block/core/storage/walstore.go | 4 ++-- .../core/storage/walstore_v3_test.go | 23 +++++++++++++------ .../docs/design/wal-v3-burst-admission.md | 10 +++++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/seaweed-block/core/storage/walstore.go b/seaweed-block/core/storage/walstore.go index 0f1d045aa9..978ba17fcd 100644 --- a/seaweed-block/core/storage/walstore.go +++ b/seaweed-block/core/storage/walstore.go @@ -415,8 +415,8 @@ func (s *WALStore) walUsedFraction() float64 { d, floor, valid := s.v3.pub.walSnapshotV3() w.mu.Lock() defer w.mu.Unlock() - if !valid || d.WALSize == 0 || d.Nonce != w.nonce || w.head < floor { - return 1 // uncertain space is not admission headroom + if !valid || d.WALSize == 0 || d.Nonce != w.nonce || w.head < floor || w.head-floor > d.WALSize { + return 0 // append's binding validation still refuses; this grants no reuse } return float64(w.head-floor) / float64(d.WALSize) } diff --git a/seaweed-block/core/storage/walstore_v3_test.go b/seaweed-block/core/storage/walstore_v3_test.go index d23292d9e4..f47d8f1596 100644 --- a/seaweed-block/core/storage/walstore_v3_test.go +++ b/seaweed-block/core/storage/walstore_v3_test.go @@ -402,8 +402,9 @@ func TestWALStoreV3RefusesPathsOfLaterRows(t *testing.T) { // codex01 row 5 P1-1: a batch's acknowledgement rechecks the store fault // under the store lock. Schedule, in both modes: batch A's slot write is -// parked (A holds descMu); B's Write takes s.mu and waits on descMu in the -// writer's snapshot; A is released, B's pwrite fails and latches while B +// parked (A holds descMu); B's Write, already past capacity admission, +// takes s.mu exclusively and waits on descMu in the writer's snapshot; +// A is released, B's pwrite fails and latches while B // still holds s.mu; A must then refuse without advancing the acknowledged W. func TestWALStoreV3SyncRechecksTheFaultAtTheAckBoundary(t *testing.T) { for _, mode := range []WMode{WModeLagged, WModeStrict} { @@ -421,16 +422,24 @@ func TestWALStoreV3SyncRechecksTheFaultAtTheAckBoundary(t *testing.T) { once.Do(func() { close(parked); <-release }) return nil } - aErr := make(chan error, 1) - go func() { _, err := s.Sync(); aErr <- err }() - waitV3(t, parked, "the parked publication") + // Finish B's admission before A parks descMu. Native capacity sampling + // itself may briefly hold s.mu shared; that is not the append boundary. + admitted, appendB := make(chan struct{}), make(chan struct{}) + resumeB := sync.OnceFunc(func() { close(appendB) }) + t.Cleanup(resumeB) + s.testAfterAdmit = func() { close(admitted); <-appendB } boom := errors.New("injected append write error") s.v3.w.writeAt = func([]byte, int64) (int, error) { return 0, boom } bErr := make(chan error, 1) go func() { _, err := s.Write(3, blk(3)); bErr <- err }() + waitV3(t, admitted, "B after capacity admission") + aErr := make(chan error, 1) + go func() { _, err := s.Sync(); aErr <- err }() + waitV3(t, parked, "the parked publication") + resumeB() deadline := time.Now().Add(10 * time.Second) - for s.mu.TryLock() { // wait until B holds s.mu (it then blocks on descMu) - s.mu.Unlock() + for s.mu.TryRLock() { // only an exclusive append owner defeats TryRLock + s.mu.RUnlock() if time.Now().After(deadline) { t.Fatal("timed out waiting for B to take s.mu") } diff --git a/seaweed-block/docs/design/wal-v3-burst-admission.md b/seaweed-block/docs/design/wal-v3-burst-admission.md index 1dc11b2da5..dd29a0dbf0 100644 --- a/seaweed-block/docs/design/wal-v3-burst-admission.md +++ b/seaweed-block/docs/design/wal-v3-burst-admission.md @@ -16,7 +16,8 @@ place. The sampler holds store.mu shared while selecting the writer, snapshots the descriptor/floor, releases descMu, then samples head under writer.mu. It releases all these locks before admission can sleep or wait. Existing publication order is unchanged; there is no fsync, slot/map write, early acknowledgement or -new reuse permission in this callback. A missing/unbound writer reports full. +new reuse permission in this callback. A missing/unbound writer remains an append-binding refusal, not capacity pressure; +the existing typed guard runs without a pressure wait. Legacy fixtures keep the original legacy occupancy. Very large batches, concurrent already-admitted requests or a fully unsynced ring can still exhaust space; this change is not a reservation scheme or a guarantee for every burst. @@ -35,3 +36,10 @@ uses actual session dispatch, asserts error status, reason logging exactly once, and no failure log on success. INV-WAL-V3-ADMISSION-001 and INV-FE-FLUSH-SYNC-001 record these checks. The durability/format model is unchanged; no new TLC or mounted performance claim is made. + +The fault-at-ACK-boundary control parks writer B after existing capacity +admission, before A's held slot publication, then requires B to own store.mu +exclusively (TryRLock fails) before releasing A. A shared sampling lock cannot +stand in for that handshake. Its injected failing append and no-W-advance +assertions remain unchanged. The half-reset control keeps its original typed +binding-refusal assertion. From ce1cba2f82e403edc8f23d28d247beaa99d46723 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 15:17:39 -0800 Subject: [PATCH 4/7] fix: keep missing-writer binding error out of pressure wait --- seaweed-block/core/storage/walstore.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/storage/walstore.go b/seaweed-block/core/storage/walstore.go index 978ba17fcd..78cb50d0a5 100644 --- a/seaweed-block/core/storage/walstore.go +++ b/seaweed-block/core/storage/walstore.go @@ -410,8 +410,10 @@ func (s *WALStore) walUsedFraction() float64 { } w := s.v3.w if w == nil { - return 1 - } // recovery/reset has not admitted a writer yet + // Not a capacity decision: append must retain its typed binding refusal + // without waiting for pressure that cannot be relieved before Recover. + return 0 + } d, floor, valid := s.v3.pub.walSnapshotV3() w.mu.Lock() defer w.mu.Unlock() From cf888fa844be25f8c1f3e21d5870b6934a06bc01 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 15:52:58 -0800 Subject: [PATCH 5/7] test: cover native v3 admission liveness across five WAL laps --- .../storage/walstore_admission_v3_test.go | 130 ++++++++++++++++++ .../core/transport/catchup_format_v3_test.go | 8 +- 2 files changed, 135 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/storage/walstore_admission_v3_test.go b/seaweed-block/core/storage/walstore_admission_v3_test.go index d357907be7..d818b145a4 100644 --- a/seaweed-block/core/storage/walstore_admission_v3_test.go +++ b/seaweed-block/core/storage/walstore_admission_v3_test.go @@ -1,8 +1,11 @@ package storage import ( + "bytes" + "errors" "path/filepath" "testing" + "time" ) func TestWALStoreV3AdmissionUsesNativeOccupancy(t *testing.T) { @@ -39,3 +42,130 @@ func TestWALStoreV3AdmissionUsesNativeOccupancy(t *testing.T) { t.Fatalf("both-slot-released occupancy=%g", got) } } + +// Five physical ring sizes, with the real background flusher and periodic +// durable Syncs. The small geometry keeps this regression a fast unit test; +// the public-provider control separately exercises the default 64 MiB WAL. +func TestWALStoreV3AdmissionBurstFiveRings(t *testing.T) { + const walSize = 64 * 1024 + const blocks = 5 * walSize / 4096 + s, err := createMappedWALStoreV3ForTest(filepath.Join(t.TempDir(), "volume"), blocks, 4096, walSize, WModeStrict, 4) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = s.Close() }) + for i := uint32(0); i < blocks; i++ { + if _, err := s.Write(i, blk(byte(i+1))); err != nil { + t.Fatalf("write %d of %d: %v", i, blocks, err) + } + if (i+1)%10 == 0 { + if _, err := s.Sync(); err != nil { + t.Fatal(err) + } + } + } + for i := uint32(0); i < blocks; i++ { + if got, err := s.Read(i); err != nil || !bytes.Equal(got, blk(byte(i+1))) { + t.Fatalf("readback %d: %v", i, err) + } + } + if floor, ok := s.v3.pub.reuseFloor(); !ok || floor <= walSize { + t.Fatalf("no actual multi-lap reuse: %d %v", floor, ok) + } +} + +func admissionPressureV3(t *testing.T, records int) *WALStore { + t.Helper() + s, err := createMappedWALStoreV3ForTest(filepath.Join(t.TempDir(), "volume"), 32, 4096, 64*1024, WModeStrict, 4) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = s.Close() }) + s.DisableAutoFlushForRecoveryTest() + for i := 0; i < records; i++ { + if _, err := s.Write(uint32(i), blk(byte(i+1))); err != nil { + t.Fatal(err) + } + } + if _, err := s.Sync(); err != nil { + t.Fatal(err) + } + return s +} + +func TestWALStoreV3AdmissionSoftThrottles(t *testing.T) { + s := admissionPressureV3(t, 12) + var delay time.Duration + s.admission.sleepFn = func(d time.Duration) { delay += d } + if err := s.admission.Acquire(time.Second); err != nil { + t.Fatal(err) + } + s.admission.Release() + if s.admission.PressureState() != "soft" || delay <= 0 || delay > 5*time.Millisecond { + t.Fatalf("soft throttle: state=%s delay=%v", s.admission.PressureState(), delay) + } +} + +func TestWALStoreV3AdmissionStallDeadlineAndResume(t *testing.T) { + s := admissionPressureV3(t, 15) + if err := s.admission.Acquire(10 * time.Millisecond); !errors.Is(err, errWALFull) { + if err == nil { + s.admission.Release() + } + t.Fatalf("stalled flusher must reach bounded deadline: %v", err) + } + notified := make(chan struct{}, 1) + notify := s.admission.notifyFn + s.admission.notifyFn = func() { + select { + case notified <- struct{}{}: + default: + } + notify() + } + done := make(chan error, 1) + go func() { + err := s.admission.Acquire(time.Second) + if err == nil { + s.admission.Release() + } + done <- err + }() + select { + case <-notified: + case <-time.After(time.Second): + t.Fatal("pressure did not wake flusher") + } + select { + case err := <-done: + t.Fatalf("admitted before stalled flusher reclaimed: %v", err) + default: + } + if err := s.flusher.flushOnce(); err != nil { + t.Fatal(err) + } + select { + case err := <-done: + if err != nil { + t.Fatal(err) + } + case <-time.After(2 * time.Second): + t.Fatal("reclaim did not release waiter") + } + if got := s.admission.PressureState(); got != "normal" { + t.Fatalf("post-checkpoint pressure=%s", got) + } +} + +func TestWALStoreV3AdmissionCloseEndsPressureWait(t *testing.T) { + s := admissionPressureV3(t, 15) + if err := s.Close(); err != nil { + t.Fatal(err) + } + if err := s.admission.Acquire(time.Second); !errors.Is(err, errVolumeClosed) { + if err == nil { + s.admission.Release() + } + t.Fatalf("closed pressured store: %v", err) + } +} diff --git a/seaweed-block/core/transport/catchup_format_v3_test.go b/seaweed-block/core/transport/catchup_format_v3_test.go index 4c78884114..5694c63278 100644 --- a/seaweed-block/core/transport/catchup_format_v3_test.go +++ b/seaweed-block/core/transport/catchup_format_v3_test.go @@ -326,7 +326,9 @@ func TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled(t *testing.T) { } t.Cleanup(func() { _ = primary.Close() }) primary.DisableAutoFlushForRecoveryTest() - for i := 1; i <= 250; i++ { + // Leave admission headroom while the flusher is deliberately disabled. + // The post-checkpoint writes still cross the physical 1 MiB ring boundary. + for i := 1; i <= 200; i++ { if _, err := primary.Write(0, v3RepBlk(byte(i))); err != nil { t.Fatal(err) } @@ -350,7 +352,7 @@ func TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled(t *testing.T) { exec := NewBlockExecutor(primary, l.Addr()) closed := make(chan adapter.SessionCloseResult, 1) exec.SetOnSessionClose(func(r adapter.SessionCloseResult) { closed <- r }) - if err := exec.StartCatchUp("r1", 1, 1, 1, 1, 251); err != nil { + if err := exec.StartCatchUp("r1", 1, 1, 1, 1, 201); err != nil { t.Fatal(err) } select { @@ -361,7 +363,7 @@ func TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled(t *testing.T) { if err := storage.FlushMappedWALStoreV3Test(primary); err != nil { t.Fatal(err) } - for i := 251; i <= 270; i++ { + for i := 201; i <= 270; i++ { if _, err := primary.Write(0, v3RepBlk(byte(i%256))); err != nil { t.Fatal(err) } From cd5d7db0ed83f22e25a964a98ef72b0f42eed1fe Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 15:54:34 -0800 Subject: [PATCH 6/7] docs: audit v3 admission and reclaim liveness replacements --- .../format-v3-legacy-test-inventory.json | 27 ++++------ .../design/format-v3-legacy-test-inventory.md | 53 +++++++++++++++++-- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/seaweed-block/docs/design/format-v3-legacy-test-inventory.json b/seaweed-block/docs/design/format-v3-legacy-test-inventory.json index 76c5aeaa8a..40e02c562c 100644 --- a/seaweed-block/docs/design/format-v3-legacy-test-inventory.json +++ b/seaweed-block/docs/design/format-v3-legacy-test-inventory.json @@ -713,8 +713,8 @@ ], "reason": "v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors", "v3_controls": [ - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime" + "TestWALStoreV3AdmissionBurstFiveRings", + "TestWALStoreV3AdmissionUsesNativeOccupancy" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -767,8 +767,9 @@ ], "reason": "v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors", "v3_controls": [ - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime" + "TestWALStoreV3AdmissionUsesNativeOccupancy", + "TestWALStoreV3AdmissionStallDeadlineAndResume", + "TestWALStoreV3AdmissionBurstFiveRings" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -1156,10 +1157,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate", + "TestWALStoreV3HalfResetRefusesWritesUntilRecover" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -1711,10 +1710,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestWALStoreV3ReclaimKeepsPartialBatchAndRetention", + "TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -1726,10 +1723,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestWALIOV3_FloorAndPwriteFailureRefuse", + "TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, diff --git a/seaweed-block/docs/design/format-v3-legacy-test-inventory.md b/seaweed-block/docs/design/format-v3-legacy-test-inventory.md index b8f0349021..c92b30c044 100644 --- a/seaweed-block/docs/design/format-v3-legacy-test-inventory.md +++ b/seaweed-block/docs/design/format-v3-legacy-test-inventory.md @@ -64,11 +64,11 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser | `core/storage/walstore_checkpoint_safety_test.go::TestFlusherSnapshotCannotOverwriteLaterDirectBase` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/flusher_snapshot_cut_test.go::TestFlusherSnapshotCutPreservesSyncedWrites` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | | `core/storage/walstore_checkpoint_safety_test.go::TestFlusherWALSlotMismatchFailsClosed` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | -| `core/storage/flusher_test.go::TestFlusher_AdvancesCheckpointBeforeReadFromExtent` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | +| `core/storage/flusher_test.go::TestFlusher_AdvancesCheckpointBeforeReadFromExtent` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3AdmissionBurstFiveRings`, `TestWALStoreV3AdmissionUsesNativeOccupancy` | | `core/storage/flusher_test.go::TestFlusher_ConcurrentWriteRaceLBAStaysFresh` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | | `core/storage/flusher_test.go::TestFlusher_ManyDirtyEntriesCheckpointStaysCorrect` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | | `core/storage/flusher_test.go::TestFlusher_RecoveryHonorsCheckpoint` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | -| `core/storage/flusher_test.go::TestFlusher_ReleasesWALPressureAfterCheckpoint` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | +| `core/storage/flusher_test.go::TestFlusher_ReleasesWALPressureAfterCheckpoint` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3AdmissionUsesNativeOccupancy`, `TestWALStoreV3AdmissionStallDeadlineAndResume`, `TestWALStoreV3AdmissionBurstFiveRings` | | `core/storage/chunk_restore_test.go::TestFreshRestoreBitmapStartsAtClaimedHEAD` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` | | `core/storage/flusher_test.go::TestRecovery_DeterministicAcrossMultipleOpens` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | | `core/storage/walstore_checkpoint_safety_test.go::TestRunningFlusherCannotOverwriteDirectBase` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | @@ -94,7 +94,7 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser | `core/storage/walstore_checkpoint_safety_test.go::TestWALStoreMutationAPIsRejectAfterClose` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_activation_test.go::TestWALStoreProductionRefusesLegacyWithoutMutation` | legacy input construction for the native public-refusal control itself; the production test stays on v3 | `TestWALStoreProductionRefusesLegacyWithoutMutation` | | `core/storage/walstore_sticky_race_test.go::TestWALStoreQueuedSyncAfterAFailedFsyncIsRefused` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | -| `core/storage/walstore_persisted_tail_test.go::TestWALStoreRecoverBoundsPersistFailureRefusesAppendsUntilRetry` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | +| `core/storage/walstore_persisted_tail_test.go::TestWALStoreRecoverBoundsPersistFailureRefusesAppendsUntilRetry` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3HalfResetRefusesWritesUntilRecover` | | `core/storage/walstore_midhistory_hole_test.go::TestWALStoreRecoverKeepsATornTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_recovery_frontier_gap_test.go::TestWALStoreRecoverKeepsSyncedEntriesAboveAnUnpersistedFrontierJump` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_recovery_lww_test.go::TestWALStoreRecoverLastWriterWinsAcrossScanOrder` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | @@ -131,10 +131,53 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser | `core/storage/walstore_recycle_pin_test.go::TestWALStore_RecycleGate_SourceActive_ClampsAtFloor` | fabricated v2 checkpoint/retention geometry; v3 replacement drives real acknowledged writes and both slots | `TestWALStoreV3RecycleFloorCompatibilityMatrix`, `TestWALStoreV3RetentionCompatibilityMatrix`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention` | | `core/storage/walstore_recycle_pin_test.go::TestWALStore_RecycleGate_SourceInactive_LegacyBehavior` | fabricated v2 checkpoint/retention geometry; v3 replacement drives real acknowledged writes and both slots | `TestWALStoreV3RecycleFloorCompatibilityMatrix`, `TestWALStoreV3RetentionCompatibilityMatrix`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention` | | `core/storage/walstore_format_admission_test.go::TestWALStore_UnknownFormatWithoutFactoryRefused` | raw frozen v2 codec/format fixtures remain; v3 has a distinct CRC32C/binding/dual-slot byte contract | `TestWALIOV3_RealWriterReopenScan`, `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestWALStoreProductionRefusesLegacyWithoutMutation` | -| `core/storage/walstore_persisted_tail_test.go::TestWALWriterBatchReuseIsBoundedByTheDurableTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | -| `core/storage/walstore_persisted_tail_test.go::TestWALWriterReuseIsBoundedByTheDurableTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | +| `core/storage/walstore_persisted_tail_test.go::TestWALWriterBatchReuseIsBoundedByTheDurableTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint` | +| `core/storage/walstore_persisted_tail_test.go::TestWALWriterReuseIsBoundedByTheDurableTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_FloorAndPwriteFailureRefuse`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | | `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectFailureRetainsDirtyWAL` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectSupersededWALDoesNotReappearAfterRestart` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectSupersedesPriorDirtyWAL` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | Native typed-error controls use the owned-map v3 store directly: `TestChunkCut_UploadFailureIsRemoteUnavailable` checks both upload error causes; `TestChunkCut_ClosedLayerIsTyped` checks the closed-cut cause; `TestChunkCut_CASLostToMovedHeadIsHeadConflict` checks ambiguous CAS with a moved HEAD remains a conflict, not fencing. They are not legacy coverage mappings. `TestLegacyFixtureIsolationRejectsFunctionValues` exercises direct calls, package/local aliases and function arguments against the same reference guard. CI executes both default and explicit tagged configurations. + +## Liveness audit after the native admission regression + +The earlier replacement matrix mapped checkpoint safety to generic recovery +controls. That did not test the *binding* of the common admission controller to +v3 occupancy. The production closure was therefore incomplete: the legacy writer +remained at zero and no test crossed the default ring while relying on automatic +pressure relief. Codec, manual-flush and safety tests could all pass. + +The audit inspected the retained legacy constructor inventory and storage tests +using admission, pressure, throttling, `errWALFull`, wait/timeout and stalled-flusher +paths. The five concrete retained controls above now name their native counterparts: +`TestFlusher_AdvancesCheckpointBeforeReadFromExtent`, +`TestFlusher_ReleasesWALPressureAfterCheckpoint`, +`TestWALWriterReuseIsBoundedByTheDurableTail`, +`TestWALWriterBatchReuseIsBoundedByTheDurableTail`, and +`TestWALStoreRecoverBoundsPersistFailureRefusesAppendsUntilRetry`. +The last three include safety gates needed to make reuse liveness safe; v3's +sticky persistence failure intentionally requires physical reopen rather than +v2's same-instance retry. These are not claimed to have identical retry semantics. +`TestWriteExtentDirectSupersedesPriorDirtyWAL` also mentions pressure, but tests +BASE supersession, not admission; its existing install/map mapping stays intact. +Raw writer controls remain format-specific; no test is removed. + +| Behaviour | Native-v3 control | Scope | +| --- | --- | --- | +| Healthy burst and automatic pressure relief | `TestWALStoreV3AdmissionBurstFiveRings` | Fresh mapped 64 KiB ring, five ring sizes of writes, Sync every ten blocks, real automatic flusher, all submitted bytes read back; legacy-sampler mutant must fail this test | +| Production default geometry and frontend Flush | `TestWALStoreChunkV3_SequentialBurstFlush` | Public provider, 64 MiB WAL, 320 MiB via NVMe handler, periodic Flush and literal-byte readback | +| Occupancy and checkpoint pressure reset | `TestWALStoreV3AdmissionUsesNativeOccupancy` | Actual append size and both-slot released floor, not a mocked pressure value | +| Soft-watermark throttling | `TestWALStoreV3AdmissionSoftThrottles` | Real occupied v3 ring drives a positive bounded soft delay; only sleep is recorded | +| Hard watermark, stopped flusher, timeout and resumed progress | `TestWALStoreV3AdmissionStallDeadlineAndResume` | Native occupied ring, bounded timeout, waiter remains blocked until actual checkpoint/reclaim then resumes | +| Close during pressure | `TestWALStoreV3AdmissionCloseEndsPressureWait` | Closed pressured store refuses with the typed close error rather than admitting | +| Idle/admission rollover without a new checkpoint | `TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint` | Both single/batch admission triggers plus idle and unchanged-checkpoint paths | +| Flusher persistence fault | `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore` | Real owned-map failure latches the store; no false progress or unsafe admission | + +There were no dedicated `walAdmission` unit tests in the retained v2 suite for +soft delay, hard-wait timeout or stopped-flusher resumption. Those gaps are covered +by the new native tests rather than reported as already covered. The new small-ring +tests use the production engine, controller and flusher with test-only geometry; +they do not replace the public default-size provider control. They preserve the +existing bounded admission policy, not a reservation guarantee for oversized or +concurrently pre-admitted batches, or a promise that an entirely unsynced ring can +reclaim unacknowledged bytes. From 0ff432fbe9e37d4ab260e52c8e16da10dd0aacec Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 16:02:47 -0800 Subject: [PATCH 7/7] docs: pin native tail reuse controls in the liveness audit --- .../format-v3-legacy-test-inventory.json | 18 ++++++------------ .../design/format-v3-legacy-test-inventory.md | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/seaweed-block/docs/design/format-v3-legacy-test-inventory.json b/seaweed-block/docs/design/format-v3-legacy-test-inventory.json index 40e02c562c..9d5b50a2dc 100644 --- a/seaweed-block/docs/design/format-v3-legacy-test-inventory.json +++ b/seaweed-block/docs/design/format-v3-legacy-test-inventory.json @@ -1052,10 +1052,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestWALStoreV3CheckpointReclaimsAcrossRingLaps", + "TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -1083,10 +1081,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestWALStoreV3ReclaimRetiresReferencesBeforeReuse", + "TestWALStoreV3CheckpointReclaimsAcrossRingLaps" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, @@ -1221,10 +1217,8 @@ ], "reason": "raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes", "v3_controls": [ - "TestWALIOV3_RealWriterReopenScan", - "TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes", - "TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash", - "TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness" + "TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery", + "TestWALStoreV3FenceTouchesNoByteBeforeTheHead" ], "todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b" }, diff --git a/seaweed-block/docs/design/format-v3-legacy-test-inventory.md b/seaweed-block/docs/design/format-v3-legacy-test-inventory.md index c92b30c044..c88358f900 100644 --- a/seaweed-block/docs/design/format-v3-legacy-test-inventory.md +++ b/seaweed-block/docs/design/format-v3-legacy-test-inventory.md @@ -87,9 +87,9 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser | `core/storage/walstore_sticky_race_test.go::TestWALStoreExtentFsyncFaultAfterThePublicationCheck` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_sticky_race_test.go::TestWALStoreExtentFsyncFaultDuringDirectFrontierPublication` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_batch_lsn_reuse_test.go::TestWALStoreFailedBatchAppendDoesNotRevertALaterAckedWrite` | v2 opt-in batch framing/failure injection; v3 batch is native and nonce-bound | `TestWALStoreV3BatchRoundTripAcrossACrash`, `TestWALStoreV3TornBatchIsAllOrNothing`, `TestWALStoreV3InstrumentationIncludesBatch` | -| `core/storage/walstore_persisted_tail_test.go::TestWALStoreFlushPersistsTheReleasedTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | +| `core/storage/walstore_persisted_tail_test.go::TestWALStoreFlushPersistsTheReleasedTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | | `core/storage/walstore_sticky_race_test.go::TestWALStoreFsyncsOfTheFileAreSerialized` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | -| `core/storage/walstore_persisted_tail_test.go::TestWALStoreFullFlushThenTornWrapKeepsSyncedRecords` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | +| `core/storage/walstore_persisted_tail_test.go::TestWALStoreFullFlushThenTornWrapKeepsSyncedRecords` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALStoreV3ReclaimRetiresReferencesBeforeReuse`, `TestWALStoreV3CheckpointReclaimsAcrossRingLaps` | | `core/storage/walstore_sticky_race_test.go::TestWALStoreHeldWorkersSettleOnAFailurePath` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_checkpoint_safety_test.go::TestWALStoreMutationAPIsRejectAfterClose` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` | | `core/storage/walstore_activation_test.go::TestWALStoreProductionRefusesLegacyWithoutMutation` | legacy input construction for the native public-refusal control itself; the production test stays on v3 | `TestWALStoreProductionRefusesLegacyWithoutMutation` | @@ -98,7 +98,7 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser | `core/storage/walstore_midhistory_hole_test.go::TestWALStoreRecoverKeepsATornTail` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_recovery_frontier_gap_test.go::TestWALStoreRecoverKeepsSyncedEntriesAboveAnUnpersistedFrontierJump` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_recovery_lww_test.go::TestWALStoreRecoverLastWriterWinsAcrossScanOrder` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | -| `core/storage/walstore_persisted_tail_test.go::TestWALStoreRecoverPersistsTheRecoveredBounds` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | +| `core/storage/walstore_persisted_tail_test.go::TestWALStoreRecoverPersistsTheRecoveredBounds` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3FenceTouchesNoByteBeforeTheHead` | | `core/storage/walstore_recovery_hardening_test.go::TestWALStoreRecoverReconstructsLegacyWrappedRetainedWindow` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_recovery_hardening_test.go::TestWALStoreRecoverRejectsOverflowingBatchGeometry` | raw v2 header/window/IEEE-CRC/permissive scan assumptions; native v3 refuses holes below W and fences rolled-back suffixes | `TestWALIOV3_RealWriterReopenScan`, `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestDurableStartup_Issue51_WALStoreV3CommittedHoleBlocksReadiness` | | `core/storage/walstore_legacy_trim_test.go::TestWALStoreRecoverReplaysLegacyRangeTrim` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | @@ -181,3 +181,15 @@ they do not replace the public default-size provider control. They preserve the existing bounded admission policy, not a reservation guarantee for oversized or concurrently pre-admitted batches, or a promise that an entirely unsynced ring can reclaim unacknowledged bytes. + +The adjacent tail-persistence/reuse safety rows are also made specific: +`TestWALStoreFlushPersistsTheReleasedTail`, +`TestWALStoreRecoverPersistsTheRecoveredBounds`, and +`TestWALStoreFullFlushThenTornWrapKeepsSyncedRecords` now cite the native +both-slot, real multi-lap/reopen and retired-dirty-reference controls above. +These are necessary reuse-safety checks, not independent backpressure tests. +The scope of this audit is storage WAL capacity and pressure-driven progress; +`TestWALStoreCloseWaitsForInflightSync` is a lifecycle/Sync join control, not a +capacity waiter or flusher-stall oracle, and its old generic mapping must not be +read as proving the native capacity behavior. Capture/BASE reconciliation waits +likewise remain in their separate protocol inventory.