mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
feat(recovery,storage): BASE install seam with a handle; dual-lane receiver on it (row 9b)
DESIGN r17.3.1 section 8.7: - BaseInstallPreparer.BeginBaseInstall(baseLSN, installID) returns an InstallHandle (WriteBase, ApplyInstallEntry, MarkBaseComplete). The v3 WALStore runs the row 9a begin; a v2 WALStore and stores without the seam get the legacy handle, which keeps their exact pre-seam behaviour (WriteExtentDirect, ApplyEntry, AdvanceFrontier(baseLSN)) and stages a BaseStager store lazily before the first BASE block or completion. parallelwal's staging step is renamed BaseStager.BeginBaseStage; the legacy replica caller uses it unchanged (row 10 rewrites that caller). - The dual-lane Receiver begins the install at SessionStart, inside the counted section, at FromLSN under a fresh random ID; RebuildSession writes, applies and completes only through the handle, and MarkBaseComplete's error now fails the session with no ack. - Tagged (swblock_format_v3_test) controls through the real receiver on a dark v3 store: the positive rebuild, the held-write drain, the parked frame for both lanes, and a superseded BaseDone failing without an ack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5d5dedcfb6
commit
f08ee20c0b
12 files changed
+506
-53
No files matched your search
@@ -27,7 +27,11 @@ import (
|
||||
// This type knows nothing about pin_floor, primary recycle, wire
|
||||
// protocol, or barrier ack. Those live in layer 2.
|
||||
type RebuildSession struct {
|
||||
store storage.LogicalStorage
|
||||
store storage.LogicalStorage
|
||||
// install is the BASE install handle (DESIGN r17.3.1 section 8.7): every
|
||||
// BASE write, install-lane apply and the completion go through it. The
|
||||
// receiver begins the install and sets it; otherwise the legacy handle.
|
||||
install storage.InstallHandle
|
||||
baseFrontierHint uint64 // snapshot pin/frontier hint for BASE lane; not a completion predicate
|
||||
|
||||
mu sync.Mutex
|
||||
@@ -75,6 +79,7 @@ type RebuildSession struct {
|
||||
func NewRebuildSession(store storage.LogicalStorage, baseFrontierHint uint64) *RebuildSession {
|
||||
return &RebuildSession{
|
||||
store: store,
|
||||
install: storage.NewLegacyInstallHandle(store, baseFrontierHint),
|
||||
baseFrontierHint: baseFrontierHint,
|
||||
bitmap: NewRebuildBitmap(store.NumBlocks()),
|
||||
}
|
||||
@@ -107,7 +112,7 @@ func (s *RebuildSession) ApplyBaseBlock(lba uint32, data []byte) (skipped bool,
|
||||
if s.bitmap.IsApplied(lba) {
|
||||
return true, nil
|
||||
}
|
||||
if err := s.store.WriteExtentDirect(lba, data); err != nil {
|
||||
if err := s.install.WriteBase(lba, data); err != nil {
|
||||
return false, fmt.Errorf("recovery: base extent-direct lba=%d: %w", lba, err)
|
||||
}
|
||||
return false, nil
|
||||
@@ -136,7 +141,7 @@ func (s *RebuildSession) ApplyWALEntry(kind WALEntryKind, lba uint32, data []byt
|
||||
if s.completed {
|
||||
return errors.New("recovery: ApplyWALEntry after session completed")
|
||||
}
|
||||
if err := s.store.ApplyEntry(lba, data, lsn); err != nil {
|
||||
if err := s.install.ApplyInstallEntry(lba, data, lsn); err != nil {
|
||||
return fmt.Errorf("recovery: wal apply lba=%d lsn=%d: %w", lba, lsn, err)
|
||||
}
|
||||
s.bitmap.MarkApplied(lba)
|
||||
@@ -178,15 +183,32 @@ func (s *RebuildSession) BaseBatchAcked(lbaUpper uint32) {
|
||||
// is installed" without needing a competing WAL apply at
|
||||
// that hint. Subsequent WAL frames above that hint advance
|
||||
// further via `ApplyEntry`'s normal side effects.
|
||||
func (s *RebuildSession) MarkBaseComplete() {
|
||||
//
|
||||
// Since the v3 seam the completion goes through the install handle and
|
||||
// returns its error (DESIGN 8.2 step 4): on an error the install stays
|
||||
// incomplete and baseDone stays false.
|
||||
func (s *RebuildSession) MarkBaseComplete() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.baseDone = true
|
||||
// §6.10 frontier reconciliation: BASE bytes are now installed
|
||||
// to extent; declare frontier at baseFrontierHint so post-rebuild
|
||||
// Sync()/Boundaries() report a non-degenerate value even on
|
||||
// BASE-only sessions (no WAL frames in this session).
|
||||
s.store.AdvanceFrontier(s.baseFrontierHint)
|
||||
// BASE-only sessions (no WAL frames in this session). The legacy
|
||||
// handle does exactly that (AdvanceFrontier); a v3 handle publishes
|
||||
// installed and moves the frontier itself.
|
||||
if err := s.install.MarkBaseComplete(); err != nil {
|
||||
return fmt.Errorf("recovery: mark BASE complete: %w", err)
|
||||
}
|
||||
s.baseDone = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetInstallHandle binds the session to the install the receiver began.
|
||||
// It is called before any BASE block or WAL entry.
|
||||
func (s *RebuildSession) SetInstallHandle(h storage.InstallHandle) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.install = h
|
||||
}
|
||||
|
||||
// SeedWalApplied seeds walApplied at session start with the receiver's
|
||||
@@ -274,7 +296,7 @@ type Status struct {
|
||||
WALApplied uint64
|
||||
BaseDone bool
|
||||
Completed bool
|
||||
BarrierWitnessed bool // §IV.2.1 A-class: latched on frameBarrierReq arrival
|
||||
BarrierWitnessed bool // §IV.2.1 A-class: latched on frameBarrierReq arrival
|
||||
BaseAckedPrefix uint32
|
||||
BitmapApplied int // count of LBAs the WAL lane has marked
|
||||
BacklogApplied uint64 // count of WALKindBacklog entries applied
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package recovery
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -50,7 +51,6 @@ type Receiver struct {
|
||||
blocksSinceLastAck uint32
|
||||
lastAckTime time.Time
|
||||
baseInstalledUpper uint32 // highest base LBA installed; advisory only in BaseBatchAck
|
||||
basePrepared bool
|
||||
|
||||
gate DualLaneGate // nil only in tests that exercise the protocol alone
|
||||
epoch uint64 // from SessionStart; checked by gate on every mutating frame
|
||||
@@ -171,7 +171,15 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
if gateErr != nil {
|
||||
return 0, gateErr
|
||||
}
|
||||
// The BASE install begins here, before any BASE block or WAL
|
||||
// entry, at the session's BASE frontier under a fresh random ID
|
||||
// (DESIGN r17.3.1 section 8.7). The begin is a mutation, so it
|
||||
// stays inside the counted section.
|
||||
install, beginErr := r.beginInstall(s.FromLSN)
|
||||
release()
|
||||
if beginErr != nil {
|
||||
return 0, newFailure(FailureSubstrate, PhaseRecvApply, beginErr)
|
||||
}
|
||||
r.sessionID = s.SessionID
|
||||
// Wire compat: sessionStart still carries TargetLSN in
|
||||
// the legacy fourth slot, but BASE frontier comes from
|
||||
@@ -181,6 +189,7 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
// as a compat/frontier-hint band and MUST NOT drive BASE
|
||||
// AdvanceFrontier.
|
||||
r.session = NewRebuildSession(r.store, s.FromLSN)
|
||||
r.session.SetInstallHandle(install)
|
||||
// Seed walApplied with fromLSN so AchievedLSN remains a
|
||||
// monotonic observation even when no WAL frames arrive.
|
||||
// Completion itself is baseDone + BarrierReq witness; the
|
||||
@@ -188,7 +197,6 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
r.session.SeedWalApplied(s.FromLSN)
|
||||
r.recvFromLSN = s.FromLSN
|
||||
r.appliedWalLSN = s.FromLSN
|
||||
r.basePrepared = false
|
||||
log.Printf("g7-debug: Receiver.Run frameSessionStart sessionID=%d fromLSN=%d targetLSN=%d numBlocks=%d", s.SessionID, s.FromLSN, s.TargetLSN, s.NumBlocks)
|
||||
|
||||
case frameBaseBlock:
|
||||
@@ -204,15 +212,8 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
if gateErr != nil {
|
||||
return 0, gateErr
|
||||
}
|
||||
prepErr := r.prepareBaseInstall()
|
||||
var applyErr error
|
||||
if prepErr == nil {
|
||||
_, applyErr = r.session.ApplyBaseBlock(lba, data)
|
||||
}
|
||||
_, applyErr := r.session.ApplyBaseBlock(lba, data)
|
||||
release()
|
||||
if prepErr != nil {
|
||||
return 0, newFailure(FailureSubstrate, PhaseRecvApply, prepErr)
|
||||
}
|
||||
if applyErr != nil {
|
||||
log.Printf("g7-debug: Receiver.Run ApplyBaseBlock err lba=%d err=%v", lba, applyErr)
|
||||
return 0, newFailure(FailureSubstrate, PhaseRecvApply,
|
||||
@@ -274,16 +275,15 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
if gateErr != nil {
|
||||
return 0, gateErr
|
||||
}
|
||||
prepErr := r.prepareBaseInstall()
|
||||
if prepErr != nil {
|
||||
release()
|
||||
return 0, newFailure(FailureSubstrate, PhaseRecvApply, prepErr)
|
||||
}
|
||||
log.Printf("g7-debug: Receiver.Run frameBaseDone baseCount=%d walCount=%d", baseCount, walCount)
|
||||
// The frontier advance is a mutation too: it stays inside the
|
||||
// counted section, so a fence cannot return while it is pending.
|
||||
r.session.MarkBaseComplete()
|
||||
// The completion (and the frontier advance) is a mutation too: it
|
||||
// stays inside the counted section, so a fence cannot return while
|
||||
// it is pending. Its error propagates (DESIGN 8.2 step 4).
|
||||
doneErr := r.session.MarkBaseComplete()
|
||||
release()
|
||||
if doneErr != nil {
|
||||
return 0, newFailure(FailureSubstrate, PhaseRecvApply, doneErr)
|
||||
}
|
||||
// Mandatory final base-lane ack — base done means primary
|
||||
// expects to know our base-installed cursor before drain
|
||||
// even if cadence wouldn't have triggered yet.
|
||||
@@ -353,17 +353,20 @@ func (r *Receiver) Run() (achievedLSN uint64, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Receiver) prepareBaseInstall() error {
|
||||
if r.basePrepared {
|
||||
return nil
|
||||
}
|
||||
if preparer, ok := r.store.(storage.BaseInstallPreparer); ok {
|
||||
if err := preparer.BeginBaseInstall(); err != nil {
|
||||
return fmt.Errorf("prepare BASE install: %w", err)
|
||||
// beginInstall begins this session's BASE install at baseLSN under a fresh
|
||||
// random, nonzero install ID (DESIGN 8.1, 8.7).
|
||||
func (r *Receiver) beginInstall(baseLSN uint64) (storage.InstallHandle, error) {
|
||||
var id [16]byte
|
||||
for id == ([16]byte{}) {
|
||||
if _, err := rand.Read(id[:]); err != nil {
|
||||
return nil, fmt.Errorf("BASE install ID: %w", err)
|
||||
}
|
||||
}
|
||||
r.basePrepared = true
|
||||
return nil
|
||||
h, err := storage.BeginInstall(r.store, baseLSN, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("begin BASE install: %w", err)
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// shouldAck evaluates the cadence rule per docs/recovery-pin-floor-wire.md §3.
|
||||
|
||||
@@ -90,7 +90,7 @@ type basePreparingStore struct {
|
||||
prepareCalls int
|
||||
}
|
||||
|
||||
func (s *basePreparingStore) BeginBaseInstall() error {
|
||||
func (s *basePreparingStore) BeginBaseStage() error {
|
||||
s.prepareCalls++
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
//go:build swblock_format_v3_test
|
||||
|
||||
package recovery
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"net"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
)
|
||||
|
||||
// Plan row 9b controls (DESIGN r17.3.1 section 8.7): the dual-lane Receiver
|
||||
// on a dark v3 store. Every BASE block and WAL entry goes through the
|
||||
// session's install handle; both admission schedules run through the real
|
||||
// receiver (WriteBase through frameBaseBlock, ApplyInstallEntry through
|
||||
// RebuildSession.ApplyWALEntry from frameWALEntry). Owner: claude03.
|
||||
// Mutants are the row 9a store mutants (shared-begin, no-id-check,
|
||||
// premature-check) plus the row 9b caller mutants named per control.
|
||||
|
||||
const v3RecvBlock = 4096
|
||||
|
||||
func v3RecvStore(t *testing.T) *storage.WALStore {
|
||||
t.Helper()
|
||||
s, err := storage.CreateWALStoreV3Test(filepath.Join(t.TempDir(), "recv.v3"), 64, v3RecvBlock)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = s.Close() })
|
||||
return s
|
||||
}
|
||||
|
||||
func v3Blk(b byte) []byte { return bytes.Repeat([]byte{b}, v3RecvBlock) }
|
||||
|
||||
// v3Peer is the primary side of one receiver connection. Every frame the
|
||||
// receiver writes is read into frames, so the receiver never blocks on the
|
||||
// synchronous pipe.
|
||||
type v3Peer struct {
|
||||
conn net.Conn
|
||||
frames chan frameType
|
||||
done chan error
|
||||
}
|
||||
|
||||
func startV3Receiver(t *testing.T, store storage.LogicalStorage) *v3Peer {
|
||||
t.Helper()
|
||||
primary, replica := net.Pipe()
|
||||
t.Cleanup(func() { primary.Close(); replica.Close() })
|
||||
p := &v3Peer{conn: primary, frames: make(chan frameType, 64), done: make(chan error, 1)}
|
||||
r := NewReceiverWithCadence(store, replica, 1, time.Hour) // an ack after every BASE block
|
||||
go func() { _, err := r.Run(); p.done <- err; replica.Close() }()
|
||||
go func() {
|
||||
for {
|
||||
ft, _, err := readFrame(primary)
|
||||
if err != nil {
|
||||
close(p.frames)
|
||||
return
|
||||
}
|
||||
p.frames <- ft
|
||||
}
|
||||
}()
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *v3Peer) send(t *testing.T, ft frameType, payload []byte) {
|
||||
t.Helper()
|
||||
if err := writeFrame(p.conn, ft, payload); err != nil {
|
||||
t.Fatalf("write frame %v: %v", ft, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *v3Peer) start(t *testing.T, fromLSN uint64) {
|
||||
t.Helper()
|
||||
p.send(t, frameSessionStart, encodeSessionStart(sessionStartPayload{SessionID: 1, FromLSN: fromLSN, NumBlocks: 64}))
|
||||
}
|
||||
|
||||
func (p *v3Peer) want(t *testing.T, ft frameType) {
|
||||
t.Helper()
|
||||
select {
|
||||
case got, ok := <-p.frames:
|
||||
if !ok || got != ft {
|
||||
t.Fatalf("frame %v (open %v), want %v", got, ok, ft)
|
||||
}
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatalf("no %v frame", ft)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *v3Peer) runErr(t *testing.T) error {
|
||||
t.Helper()
|
||||
select {
|
||||
case err := <-p.done:
|
||||
return err
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("receiver did not end")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// holdFirst returns a hook that parks the first call until release runs.
|
||||
// The rendezvous is bounded (a hook that never fires fails the test instead
|
||||
// of hanging it) and cleanup always releases.
|
||||
func holdFirst(t *testing.T) (hook func(), waitParked func(), release func()) {
|
||||
parked, gate := make(chan struct{}), make(chan struct{})
|
||||
var once sync.Once
|
||||
release = func() { once.Do(func() { close(gate) }) }
|
||||
t.Cleanup(release)
|
||||
var armed atomic.Bool
|
||||
armed.Store(true)
|
||||
waitParked = func() {
|
||||
t.Helper()
|
||||
select {
|
||||
case <-parked:
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("the held frame never reached the install hook")
|
||||
}
|
||||
}
|
||||
return func() {
|
||||
if armed.CompareAndSwap(true, false) {
|
||||
close(parked)
|
||||
<-gate
|
||||
}
|
||||
}, waitParked, release
|
||||
}
|
||||
|
||||
func readV3Recv(t *testing.T, s *storage.WALStore, lba uint32) []byte {
|
||||
t.Helper()
|
||||
b, err := s.Read(lba)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// The positive receiver rebuild: SessionStart begins the install, a BASE
|
||||
// block and a WAL entry go through the handle, BaseDone completes it
|
||||
// (installed) and the barrier completes the session. BaseLSN 5 is above
|
||||
// the checkpoint, so installed is not retired yet (8.4).
|
||||
// Mutant: a receiver that skips the begin (the legacy handle on v3) is
|
||||
// refused by the v3 store (errV3NotYet) and fails here.
|
||||
func TestReceiverV3InstallThroughTheHandle(t *testing.T) {
|
||||
s := v3RecvStore(t)
|
||||
p := startV3Receiver(t, s)
|
||||
p.start(t, 5)
|
||||
p.send(t, frameBaseBlock, encodeBaseBlock(3, v3Blk(0x33)))
|
||||
p.want(t, frameBaseBatchAck)
|
||||
if st, _ := storage.BaseStateV3Test(s); st != storage.BaseInstalling {
|
||||
t.Fatalf("state %d during the session, want installing", st)
|
||||
}
|
||||
p.send(t, frameWALEntry, encodeWALEntry(WALKindBacklog, 4, 6, v3Blk(0x44)))
|
||||
p.send(t, frameBaseDone, nil)
|
||||
p.want(t, frameBaseBatchAck)
|
||||
p.send(t, frameBarrierReq, nil)
|
||||
p.want(t, frameBarrierResp)
|
||||
if err := p.runErr(t); err != nil {
|
||||
t.Fatalf("receiver: %v", err)
|
||||
}
|
||||
if st, _ := storage.BaseStateV3Test(s); st != storage.BaseInstalled {
|
||||
t.Fatalf("state %d after BaseDone, want installed", st)
|
||||
}
|
||||
for lba, want := range map[uint32]byte{3: 0x33, 4: 0x44} {
|
||||
if got := readV3Recv(t, s, lba); !bytes.Equal(got, v3Blk(want)) {
|
||||
t.Fatalf("LBA %d = %x..., want %x", lba, got[0], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drain setup through the receiver (codex01 r12 P2): A's admitted BASE
|
||||
// write is held; B's SessionStart begin waits for it; B writes the target
|
||||
// block and stays installing; a further A frame fails A's session with
|
||||
// ErrInstallSuperseded and B's block is byte-identical.
|
||||
func TestReceiverV3HeldOldBaseWriteDrainsBeforeANewSession(t *testing.T) {
|
||||
s := v3RecvStore(t)
|
||||
a := startV3Receiver(t, s)
|
||||
a.start(t, 0)
|
||||
hook, waitParked, release := holdFirst(t)
|
||||
storage.SetInstallHooksV3Test(s, nil, hook)
|
||||
a.send(t, frameBaseBlock, encodeBaseBlock(7, v3Blk(0xAA)))
|
||||
waitParked()
|
||||
_, idA := storage.BaseStateV3Test(s)
|
||||
b := startV3Receiver(t, s)
|
||||
bSent := make(chan struct{})
|
||||
go func() {
|
||||
b.start(t, 0)
|
||||
b.send(t, frameBaseBlock, encodeBaseBlock(7, v3Blk(0xBB)))
|
||||
close(bSent)
|
||||
}()
|
||||
// B must not get past its begin while A's write is held; give a wrong
|
||||
// (shared) begin time to write first. The oracle is the bytes below.
|
||||
select {
|
||||
case ft := <-b.frames:
|
||||
if ft != frameBaseBatchAck {
|
||||
t.Fatalf("B frame %v", ft)
|
||||
}
|
||||
b.frames <- ft
|
||||
case <-time.After(300 * time.Millisecond):
|
||||
}
|
||||
release()
|
||||
a.want(t, frameBaseBatchAck)
|
||||
<-bSent
|
||||
b.want(t, frameBaseBatchAck)
|
||||
if got := readV3Recv(t, s, 7); !bytes.Equal(got, v3Blk(0xBB)) {
|
||||
t.Fatalf("LBA 7 = %x..., want B's bytes", got[0])
|
||||
}
|
||||
a.send(t, frameBaseBlock, encodeBaseBlock(7, v3Blk(0xAA)))
|
||||
if err := a.runErr(t); !errors.Is(err, storage.ErrInstallSuperseded) {
|
||||
t.Fatalf("A after the supersession: %v, want ErrInstallSuperseded", err)
|
||||
}
|
||||
if got := readV3Recv(t, s, 7); !bytes.Equal(got, v3Blk(0xBB)) {
|
||||
t.Fatalf("LBA 7 = %x... after A's stale frame, want B's bytes", got[0])
|
||||
}
|
||||
if st, id := storage.BaseStateV3Test(s); st != storage.BaseInstalling || id == idA {
|
||||
t.Fatalf("state %d id unchanged %v, want installing under B", st, id == idA)
|
||||
}
|
||||
}
|
||||
|
||||
// Premature-check setup through the receiver (codex03 r11): A's frame parks
|
||||
// before acquiring installMu; B supersedes, writes the target block and
|
||||
// stays installing; A resumes and its session fails with
|
||||
// ErrInstallSuperseded, B's block byte-identical. WriteBase runs through
|
||||
// frameBaseBlock, ApplyInstallEntry through frameWALEntry.
|
||||
func TestReceiverV3ParkedOldFrameIsRefusedAfterANewSession(t *testing.T) {
|
||||
for _, lane := range []string{"base", "wal"} {
|
||||
t.Run(lane, func(t *testing.T) {
|
||||
s := v3RecvStore(t)
|
||||
a := startV3Receiver(t, s)
|
||||
a.start(t, 0)
|
||||
hook, waitParked, release := holdFirst(t)
|
||||
storage.SetInstallHooksV3Test(s, hook, nil)
|
||||
if lane == "base" {
|
||||
a.send(t, frameBaseBlock, encodeBaseBlock(7, v3Blk(0xAA)))
|
||||
} else {
|
||||
a.send(t, frameWALEntry, encodeWALEntry(WALKindBacklog, 7, 1, v3Blk(0xAA)))
|
||||
}
|
||||
waitParked()
|
||||
b := startV3Receiver(t, s)
|
||||
b.start(t, 0)
|
||||
b.send(t, frameBaseBlock, encodeBaseBlock(7, v3Blk(0xBB)))
|
||||
b.want(t, frameBaseBatchAck)
|
||||
release()
|
||||
if err := a.runErr(t); !errors.Is(err, storage.ErrInstallSuperseded) {
|
||||
t.Fatalf("parked A (%s): %v, want ErrInstallSuperseded", lane, err)
|
||||
}
|
||||
if got := readV3Recv(t, s, 7); !bytes.Equal(got, v3Blk(0xBB)) {
|
||||
t.Fatalf("LBA 7 = %x..., want B's bytes", got[0])
|
||||
}
|
||||
if st, _ := storage.BaseStateV3Test(s); st != storage.BaseInstalling {
|
||||
t.Fatalf("state %d, want installing under B", st)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A superseded session's BaseDone fails (DESIGN 8.2 step 4): the
|
||||
// completion error propagates, no BaseBatchAck is sent and the volume stays
|
||||
// installing under the newer ID. Mutant: a receiver that discards the
|
||||
// MarkBaseComplete error acks and fails here.
|
||||
func TestReceiverV3SupersededBaseDoneFailsWithoutAnAck(t *testing.T) {
|
||||
s := v3RecvStore(t)
|
||||
a := startV3Receiver(t, s)
|
||||
a.start(t, 0)
|
||||
a.send(t, frameBaseBlock, encodeBaseBlock(2, v3Blk(0x22)))
|
||||
a.want(t, frameBaseBatchAck)
|
||||
b := startV3Receiver(t, s)
|
||||
b.start(t, 0)
|
||||
b.send(t, frameBaseBlock, encodeBaseBlock(3, v3Blk(0x33)))
|
||||
b.want(t, frameBaseBatchAck)
|
||||
a.send(t, frameBaseDone, nil)
|
||||
if err := a.runErr(t); !errors.Is(err, storage.ErrInstallSuperseded) {
|
||||
t.Fatalf("A BaseDone: %v, want ErrInstallSuperseded", err)
|
||||
}
|
||||
if ft, ok := <-a.frames; ok {
|
||||
t.Fatalf("A sent %v after a failed completion", ft)
|
||||
}
|
||||
if st, _ := storage.BaseStateV3Test(s); st != storage.BaseInstalling {
|
||||
t.Fatalf("state %d, want installing", st)
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,13 @@ func (s *WALStore) beginBaseInstallV3(baseLSN uint64, id [16]byte) (*installHand
|
||||
if v.w == nil {
|
||||
return nil, errWALBindingV3 // a half-published reset before its Recover
|
||||
}
|
||||
if s.chunk.Load() != nil {
|
||||
// The v3 chunk layer refuses BASE state writes and attachment while
|
||||
// installing; its side of the install protocol (the install
|
||||
// generation bump, no capture of a partly installed image) is not
|
||||
// wired yet, so an install with a layer attached fails closed.
|
||||
return nil, fmt.Errorf("%w: BASE install with an attached chunk layer", errV3NotYet)
|
||||
}
|
||||
d := v.pub.current()
|
||||
switch d.BaseState {
|
||||
case BaseInstalled:
|
||||
@@ -127,6 +134,25 @@ func (s *WALStore) beginBaseInstallV3(baseLSN uint64, id [16]byte) (*installHand
|
||||
return &installHandleV3{s: s, id: id}, nil
|
||||
}
|
||||
|
||||
// BeginBaseInstall is the BASE install seam (DESIGN 8.7). A v3 store runs
|
||||
// the section 8.1 begin; a v2 store keeps its pre-seam behaviour behind the
|
||||
// legacy handle (it had no begin step).
|
||||
func (s *WALStore) BeginBaseInstall(baseLSN uint64, installID [16]byte) (InstallHandle, error) {
|
||||
if s.v3 == nil {
|
||||
return NewLegacyInstallHandle(s, baseLSN), nil
|
||||
}
|
||||
h, err := s.beginBaseInstallV3(baseLSN, installID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// MarkBaseComplete completes this handle's install (DESIGN 8.2).
|
||||
func (h *installHandleV3) MarkBaseComplete() error { return h.s.markBaseCompleteV3(h.id) }
|
||||
|
||||
var _ BaseInstallPreparer = (*WALStore)(nil)
|
||||
|
||||
// admitV3 takes installMu shared and checks, under it, that the volume is
|
||||
// installing under h's ID (DESIGN 8.7). The caller releases it only after
|
||||
// its whole mutation.
|
||||
|
||||
@@ -452,3 +452,22 @@ func TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites(t *testing.T) {
|
||||
t.Fatal("chunk 2 reopened clean: the BASE write's UNKNOWN was lost at complete")
|
||||
}
|
||||
}
|
||||
|
||||
// Until the chunk layer's side of the v3 install protocol lands (codex03),
|
||||
// a begin with an attached chunk layer fails closed, writing nothing, so
|
||||
// no capture can upload a partly installed image. Mutant: dropping the
|
||||
// refusal begins the install with the layer attached and fails here.
|
||||
func TestBaseInstallV3BeginRefusesWithAnAttachedChunkLayer(t *testing.T) {
|
||||
s, path := newMappedCheckpointStoreV3(t)
|
||||
cfg := ctConfig(1)
|
||||
cfg.Bitmap = nil
|
||||
cfg.BarrierBound = 1
|
||||
mustAttach(t, s, newFakeChunkRemote(), cfg)
|
||||
a0, b0 := slotsV3(t, path)
|
||||
if _, err := s.beginBaseInstallV3(0, idA); !errors.Is(err, errV3NotYet) {
|
||||
t.Fatalf("begin with a chunk layer attached: err = %v, want errV3NotYet", err)
|
||||
}
|
||||
if a, b := slotsV3(t, path); a != a0 || b != b0 {
|
||||
t.Fatal("a refused begin wrote a descriptor slot")
|
||||
}
|
||||
}
|
||||
@@ -15,3 +15,27 @@ func OpenMappedWALStoreV3Test(path string) (*WALStore, error) {
|
||||
func FlushMappedWALStoreV3Test(s *WALStore) error {
|
||||
return s.flusher.flushOnce()
|
||||
}
|
||||
|
||||
// CreateWALStoreV3Test creates an unmapped dark v3 store (mode A) for the
|
||||
// tagged cross-package install controls (plan row 9b).
|
||||
func CreateWALStoreV3Test(path string, blocks, blockSize uint32) (*WALStore, error) {
|
||||
s, err := createWALStoreV3ForTest(path, blocks, blockSize, 1<<20, WModeStrict)
|
||||
if err == nil {
|
||||
s.DisableAutoFlushForRecoveryTest()
|
||||
}
|
||||
return s, err
|
||||
}
|
||||
|
||||
// SetInstallHooksV3Test sets the install admission hooks (DESIGN 8.7):
|
||||
// beforeAdmit runs in a handle mutation before it acquires installMu,
|
||||
// admitted after its ID check and before the write. nil clears a hook.
|
||||
func SetInstallHooksV3Test(s *WALStore, beforeAdmit, admitted func()) {
|
||||
s.v3.testInstallBeforeAdmit = beforeAdmit
|
||||
s.v3.testInstallAdmitted = admitted
|
||||
}
|
||||
|
||||
// BaseStateV3Test reports the selected descriptor's BASE state and ID.
|
||||
func BaseStateV3Test(s *WALStore) (BaseState, [16]byte) {
|
||||
d := s.v3.pub.current()
|
||||
return d.BaseState, d.BaseInstallID
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package storage
|
||||
|
||||
import "fmt"
|
||||
|
||||
// LogicalStorage is the V3 persistence-seam contract. It separates the
|
||||
// "what data exists, what frontier is durable" question (storage) from
|
||||
// the "what does the engine decide" question (semantic core). The
|
||||
@@ -211,11 +213,86 @@ type LogicalStorage interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
// BaseInstallPreparer is an optional rebuild capability for substrates that
|
||||
// stage BASE snapshots before making them authoritative. Recovery callers
|
||||
// invoke it once before the first BASE block (or an empty BASE completion).
|
||||
// InstallHandle is the only path for one BASE install's mutations (format
|
||||
// bump v3, DESIGN r17.3.1 section 8.7): the BASE extent writes, the
|
||||
// install-lane WAL applies and the completion, all bound to the install's
|
||||
// ID. On a v3 store a handle whose ID has been superseded changes nothing
|
||||
// and returns ErrInstallSuperseded.
|
||||
type InstallHandle interface {
|
||||
WriteBase(lba uint32, data []byte) error
|
||||
ApplyInstallEntry(lba uint32, data []byte, lsn uint64) error
|
||||
// MarkBaseComplete is DESIGN 8.2: on any error the install stays
|
||||
// incomplete and the error propagates.
|
||||
MarkBaseComplete() error
|
||||
}
|
||||
|
||||
// BaseInstallPreparer is the BASE install seam (DESIGN 8.1, 8.7): the begin
|
||||
// of one install at baseLSN under a fresh, random, nonzero installID.
|
||||
type BaseInstallPreparer interface {
|
||||
BeginBaseInstall() error
|
||||
BeginBaseInstall(baseLSN uint64, installID [16]byte) (InstallHandle, error)
|
||||
}
|
||||
|
||||
// BaseStager is the legacy optional rebuild capability for substrates that
|
||||
// stage BASE snapshots before making them authoritative (parallelwal). The
|
||||
// legacy install handle invokes it once, before the first BASE block or an
|
||||
// empty BASE completion, exactly when callers invoked it before the seam.
|
||||
type BaseStager interface {
|
||||
BeginBaseStage() error
|
||||
}
|
||||
|
||||
// BeginInstall begins one BASE install on store: through its seam when it
|
||||
// has one, otherwise with the legacy handle.
|
||||
func BeginInstall(store LogicalStorage, baseLSN uint64, installID [16]byte) (InstallHandle, error) {
|
||||
if p, ok := store.(BaseInstallPreparer); ok {
|
||||
return p.BeginBaseInstall(baseLSN, installID)
|
||||
}
|
||||
return NewLegacyInstallHandle(store, baseLSN), nil
|
||||
}
|
||||
|
||||
// NewLegacyInstallHandle returns the pre-v3 install behaviour behind the
|
||||
// handle: WriteBase is WriteExtentDirect, ApplyInstallEntry is ApplyEntry and
|
||||
// MarkBaseComplete is AdvanceFrontier(baseLSN). A BaseStager store stages
|
||||
// lazily, before the first WriteBase or MarkBaseComplete.
|
||||
func NewLegacyInstallHandle(store LogicalStorage, baseLSN uint64) InstallHandle {
|
||||
return &legacyInstallHandle{store: store, baseLSN: baseLSN}
|
||||
}
|
||||
|
||||
type legacyInstallHandle struct {
|
||||
store LogicalStorage
|
||||
baseLSN uint64
|
||||
staged bool
|
||||
}
|
||||
|
||||
func (h *legacyInstallHandle) stage() error {
|
||||
if h.staged {
|
||||
return nil
|
||||
}
|
||||
if st, ok := h.store.(BaseStager); ok {
|
||||
if err := st.BeginBaseStage(); err != nil {
|
||||
return fmt.Errorf("prepare BASE install: %w", err)
|
||||
}
|
||||
}
|
||||
h.staged = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *legacyInstallHandle) WriteBase(lba uint32, data []byte) error {
|
||||
if err := h.stage(); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.store.WriteExtentDirect(lba, data)
|
||||
}
|
||||
|
||||
func (h *legacyInstallHandle) ApplyInstallEntry(lba uint32, data []byte, lsn uint64) error {
|
||||
return h.store.ApplyEntry(lba, data, lsn)
|
||||
}
|
||||
|
||||
func (h *legacyInstallHandle) MarkBaseComplete() error {
|
||||
if err := h.stage(); err != nil {
|
||||
return err
|
||||
}
|
||||
h.store.AdvanceFrontier(h.baseLSN)
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteBatcher is an optional LogicalStorage extension for contiguous
|
||||
|
||||
@@ -1205,10 +1205,10 @@ func (s *Store) ApplyEntry(lba uint32, data []byte, lsn uint64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// BeginBaseInstall resets the inactive extent used for the next rebuild.
|
||||
// BeginBaseStage resets the inactive extent used for the next rebuild.
|
||||
// The active extent remains authoritative until Sync publishes a header that
|
||||
// atomically switches ActiveExtent.
|
||||
func (s *Store) BeginBaseInstall() error {
|
||||
func (s *Store) BeginBaseStage() error {
|
||||
s.syncMu.Lock()
|
||||
defer s.syncMu.Unlock()
|
||||
return s.resetBaseStageUnderSync()
|
||||
@@ -1418,6 +1418,6 @@ func (s *Store) extentOffsetFor(extent int, lba uint32) int64 {
|
||||
}
|
||||
|
||||
var (
|
||||
_ storage.LogicalStorage = (*Store)(nil)
|
||||
_ storage.BaseInstallPreparer = (*Store)(nil)
|
||||
_ storage.LogicalStorage = (*Store)(nil)
|
||||
_ storage.BaseStager = (*Store)(nil)
|
||||
)
|
||||
@@ -1095,7 +1095,7 @@ func TestBaseExtentHeaderFailureKeepsPriorAcknowledgedExtent(t *testing.T) {
|
||||
t.Fatalf("baseline checkpoint=%d activeExtent=%d want=(2,0)", s.checkpointLSN, s.activeExtent)
|
||||
}
|
||||
|
||||
if err := s.BeginBaseInstall(); err != nil {
|
||||
if err := s.BeginBaseStage(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.WriteExtentDirect(0, testBlock(0x77, s.BlockSize())); err != nil {
|
||||
@@ -1132,13 +1132,13 @@ func TestBaseExtentHeaderFailureKeepsPriorAcknowledgedExtent(t *testing.T) {
|
||||
|
||||
func TestBeginBaseInstallClearsAbortedStage(t *testing.T) {
|
||||
s, path := createTestStore(t)
|
||||
if err := s.BeginBaseInstall(); err != nil {
|
||||
if err := s.BeginBaseStage(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.WriteExtentDirect(3, testBlock(0x55, s.BlockSize())); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.BeginBaseInstall(); err != nil {
|
||||
if err := s.BeginBaseStage(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.AdvanceFrontier(10)
|
||||
@@ -1208,7 +1208,7 @@ func TestAdvanceFrontierWithoutBaseStageKeepsExistingData(t *testing.T) {
|
||||
|
||||
func TestNextBaseStagePreservesHeaderFallbackToCurrentExtent(t *testing.T) {
|
||||
s, path := createTestStore(t)
|
||||
if err := s.BeginBaseInstall(); err != nil {
|
||||
if err := s.BeginBaseStage(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.WriteExtentDirect(4, testBlock(0x66, s.BlockSize())); err != nil {
|
||||
@@ -1222,7 +1222,7 @@ func TestNextBaseStagePreservesHeaderFallbackToCurrentExtent(t *testing.T) {
|
||||
t.Fatalf("first BASE activeExtent=%d want=1", s.activeExtent)
|
||||
}
|
||||
|
||||
if err := s.BeginBaseInstall(); err != nil {
|
||||
if err := s.BeginBaseStage(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.mu.RLock()
|
||||
|
||||
@@ -313,8 +313,8 @@ func (r *ReplicaListener) handleConn(conn net.Conn) {
|
||||
if basePrepared {
|
||||
return nil
|
||||
}
|
||||
if preparer, ok := r.store.(storage.BaseInstallPreparer); ok {
|
||||
if err := preparer.BeginBaseInstall(); err != nil {
|
||||
if stager, ok := r.store.(storage.BaseStager); ok {
|
||||
if err := stager.BeginBaseStage(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-WAL-V3-W-001` | v3 Sync acknowledges only after an fsync covers the batch. In mode C (the default) the slot carries the previous batch's acknowledged W and the batch's single fsync covers WAL and slot; in mode A the WAL fsync precedes a slot publication with W = H. Recovery refuses (`wal_corrupt`) when the contiguous prefix R above max(CheckpointLSN, BaseLSN) is below W* = max(slot W, max trusted DurableLSN). Mode C's only unprotected acknowledged data is the newest batch, against media corruption before the next Sync or the idle refresh; `SetWMode` and the refresh close that window. Flushed entries above the published checkpoint remain retry work, so a later Sync plus cycle can advance checkpoint and map coverage together. | M1 Recovering → Serving \| RecoveryFailed; M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.syncWALBatchV3`, `refreshW`, `SetWMode`, `recoverV3`, `appendWriteV3`; `core/storage/recovery_v3.go` `decideRecoveryV3`, `contiguousPrefixV3`; `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW`, `TestWALStoreV3LegacySuperblockWritersRefuse` (`core/storage/walstore_close_v3_test.go`); `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3ModeCWindowIsExactlyTheNewestBatch`, `TestWALStoreV3RefreshAndSetWModeCloseTheWindow`, `TestWALStoreV3TornUnsyncedTailIsNeverAFalseCorrupt`, `TestWALStoreV3AppendWriteErrorLatchesTheStore`, `TestWALStoreV3FlusherWritesTheExtentButHoldsTheCheckpointUntilTheMap`, `TestWALStoreV3SyncRechecksTheFaultAtTheAckBoundary`, `TestWALStoreV3SetWModeWaitsForAHeldBatch`, `TestWALStoreV3NoBatchAcksUnderAStaleModeAfterSetWMode`, `TestWALStoreV3SetWModeCrashCases`, `TestWALStoreV3SameOpenRecoverResetsTheAcknowledgedFrontier`, `TestWALStoreV3InstallingScanErrorIsTypedNotReady`, `TestWALStoreV3FlusherCycleRunsTheIdleRefresh`, `TestWALStoreV3RefreshDuringRecoverWaitsAndPublishesNothing`, `TestWALStoreV3RecoverWaitsForABatchAckAndNothingRevivesTheCut`, `TestWALStoreV3OuterSyncCompletionIsRefusedAcrossARecovery`, `TestWALStoreV3FlusherCheckpointIsClampedToTheAcknowledgedW`, `TestWALStoreV3FlusherEmptyCycleRunsTheIdleRefresh` (`core/storage/walstore_v3_test.go`); `TestRecoveryV3Decision`, `TestRecoveryV3ContiguousPrefix` (`core/storage/recovery_v3_test.go`); `TestWALStoreV3_FlushedProgressRetriesAfterLaterSync` (`core/storage/walstore_flushed_progress_v3_test.go`) | `WALFormat` composed model (claude05, r14 run) | STUB |
|
||||
| `INV-WAL-V3-FENCE-001` | Before any append after a v3 recovery, the store zeroes exactly the logical WAL interval [E, floor+WALSize) (floor = both slots' same-nonce reuse floor) split at the physical wrap, fsyncs it through the leaf, then publishes retainedHead = E; no byte before E or outside the interval changes, so records dropped by one recovery never resurface after a second crash. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.fenceV3`, `recoverV3`; `core/storage/recovery_v3.go` `fenceRangesV3` | `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestWALStoreV3NoFenceResurrectsInBothModes`, `TestWALStoreV3FenceTouchesNoByteBeforeTheHead`, `TestWALStoreV3RecoversAHistoryEndingAtTheLastRepresentableCursor` (`core/storage/walstore_v3_test.go`); `TestRecoveryV3FenceRangesAreExact` (`core/storage/recovery_v3_test.go`) | `WALFormat` `NoResurrection` (claude05) | STUB |
|
||||
| `INV-WAL-V3-RESET-001` | A v3 nonce/position reset is refused, writing nothing, unless the dirty map is empty (no entry names an old-incarnation WAL position) and every appended LSN is checkpointed (CheckpointLSN >= appended, hence = acknowledged W). It publishes the new nonce with an empty cursor space into one slot and then the other, and is successful only after both. A crash between the two opens the new incarnation; no reuse floor exists across the two nonces, and no writer binds until Recover's head publication completes the other slot. LSNs, W and the map root are unchanged. A read holds no lock across its WAL read; it validates the whole record it read (CRC, footer, type, LBA, LSN) against the resolving dirty entry and re-resolves on a mismatch, so a position reused by the new incarnation never serves another block (LSN allocation runs on across a reset; no nonce is checked). It reports WAL damage only for an unchanged entry with the same recovery generation before and after the attempt (bumped at the start and the end of every recovery and reset); a failed pread is substrate I/O. | M1 Serving → Serving (reset, dark) | `core/storage/reset_v3.go` `WALStore.resetIncarnationV3`, `descriptorPublisherV3.resetIncarnationV3`, `halfResetV3`; `core/storage/descriptor_v3.go` `mergeDescriptorV3Mode`; `core/storage/walstore_v3.go` open and `recoverV3` | `TestResetV3RefusesWhileUncheckpointed`, `TestResetV3RefusesTheCurrentOrAZeroNonce`, `TestResetV3RetainedButCheckpointedBytesDoNotBlock`, `TestResetV3PublishesBothSlotsAndOnlyThenHasAFloor`, `TestResetV3CrashOutcomes`, `TestResetV3OrdinaryPublicationsCannotChangeTheNonce` (`core/storage/reset_v3_test.go`); `TestWALStoreV3ResetRefusesUncheckpointedOrUnacknowledgedData`, `TestWALStoreV3ResetPublishesBothSlotsAndWritesRecoverAcrossACrash`, `TestWALStoreV3ResetCrashOutcomes`, `TestWALStoreV3HalfResetRefusesWritesUntilRecover`, `TestWALStoreV3ReadParkedAcrossAResetAndOverwriteReturnsItsOwnBlock`, `TestWALStoreV3ReadMissRecheckParkedAcrossAResetReturnsItsOwnBlock`, `TestWALStoreV3ReadOfADamagedLiveRecordIsAnIntegrityFault`, `TestWALStoreV3ReadAcrossARecoveryThatReusesTheSamePositionAndLSNIsNotDamage`, `TestWALStoreV3ReadIOErrorsAreSubstrateIONotWALIntegrity`, `TestWALStoreV3ReadAdmittedBetweenRecoverBumpAndClearIsNotDamage` (`core/storage/reset_store_v3_test.go`) | `WALFormat` reset (claude05 r4.5, pending) | STUB |
|
||||
| `INV-WAL-V3-BASE-001` | A v3 BASE install begins only under `installMu` exclusive (draining the old ID's admitted mutations) and only when BaseLSN covers the acknowledged W (published or not yet), the checkpoint and every appended LSN (an unacknowledged record above BaseLSN would leave a hole behind BaseCursor; codex01 row 9a P1-1); otherwise it is refused, writing nothing, with `ErrInstallBaseUncovered` or `ErrInstallSupersedeUncovered`. It publishes installing (BaseLSN, BaseCursor = the writer head P, the ID) into both slots before the first BASE mutation. BASE extent writes and install-lane applies go only through the handle, under `installMu` shared with the state and ID checked under it (`ErrInstallSuperseded`); the install lane keeps the order and gap rules. Complete validates the ID under `installMu` exclusive, fsyncs the BASE bytes and the suffix, runs the checkpoint's metadata and chunk barriers and publishes installed with retainedTail >= BaseCursor together with a fresh owned-map candidate carrying the BASE writes' UNKNOWN (codex01 row 9a P1-2) and stops serving the superseded pre-BASE records. installing -> none is refused (no abort); installed -> none retires only once the checkpoint covers BaseLSN and both slots carry a tail at or past BaseCursor. | M1 Serving → Installing → Serving (dark) | `core/storage/base_install_v3.go` `WALStore.beginBaseInstallV3`, `installHandleV3.WriteBase`, `installHandleV3.ApplyInstallEntry`, `WALStore.markBaseCompleteV3`; `core/storage/descriptor_v3.go` `baseTransitionAllowedV3`, `retireBaseV3` | `TestBaseInstallV3BeginPublishesInstallingIntoBothSlots`, `TestBaseInstallV3BeginRefusesBelowW`, `TestBaseInstallV3BeginCoversTheAcknowledgedNotYetPublishedW`, `TestBaseInstallV3BeginRefusals`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash`, `TestBaseInstallV3InstallingToNoneIsRefused`, `TestBaseInstallV3RetiresOnlyOnceTheCheckpointCoversBaseLSN`, `TestBaseInstallV3ApplyInstallEntryOrderAndGap`, `TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin`, `TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession`, `TestBaseInstallV3BeginRefusesBelowTheHighestAppendedLSN`, `TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites` (`core/storage/base_install_v3_test.go`); `TestDescriptorV3BaseTransitionTable` | `WALFormat` handle and BASE configs (claude05 R17c, pending) | STUB |
|
||||
| `INV-WAL-V3-BASE-001` | A v3 BASE install begins only under `installMu` exclusive (draining the old ID's admitted mutations) and only when BaseLSN covers the acknowledged W (published or not yet), the checkpoint and every appended LSN (an unacknowledged record above BaseLSN would leave a hole behind BaseCursor; codex01 row 9a P1-1); otherwise it is refused, writing nothing, with `ErrInstallBaseUncovered` or `ErrInstallSupersedeUncovered`. It publishes installing (BaseLSN, BaseCursor = the writer head P, the ID) into both slots before the first BASE mutation. BASE extent writes and install-lane applies go only through the handle, under `installMu` shared with the state and ID checked under it (`ErrInstallSuperseded`); the install lane keeps the order and gap rules. Complete validates the ID under `installMu` exclusive, fsyncs the BASE bytes and the suffix, runs the checkpoint's metadata and chunk barriers and publishes installed with retainedTail >= BaseCursor together with a fresh owned-map candidate carrying the BASE writes' UNKNOWN (codex01 row 9a P1-2) and stops serving the superseded pre-BASE records. installing -> none is refused (no abort); installed -> none retires only once the checkpoint covers BaseLSN and both slots carry a tail at or past BaseCursor. | M1 Serving → Installing → Serving (dark) | `core/storage/base_install_v3.go` `WALStore.beginBaseInstallV3`, `installHandleV3.WriteBase`, `installHandleV3.ApplyInstallEntry`, `WALStore.markBaseCompleteV3`; `core/storage/descriptor_v3.go` `baseTransitionAllowedV3`, `retireBaseV3` | `TestBaseInstallV3BeginPublishesInstallingIntoBothSlots`, `TestBaseInstallV3BeginRefusesBelowW`, `TestBaseInstallV3BeginCoversTheAcknowledgedNotYetPublishedW`, `TestBaseInstallV3BeginRefusals`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash`, `TestBaseInstallV3InstallingToNoneIsRefused`, `TestBaseInstallV3RetiresOnlyOnceTheCheckpointCoversBaseLSN`, `TestBaseInstallV3ApplyInstallEntryOrderAndGap`, `TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin`, `TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession`, `TestBaseInstallV3BeginRefusesBelowTheHighestAppendedLSN`, `TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites`, `TestBaseInstallV3BeginRefusesWithAnAttachedChunkLayer` (`core/storage/base_install_v3_test.go`); `TestDescriptorV3BaseTransitionTable`; tagged `swblock_format_v3_test`: `TestReceiverV3InstallThroughTheHandle`, `TestReceiverV3HeldOldBaseWriteDrainsBeforeANewSession`, `TestReceiverV3ParkedOldFrameIsRefusedAfterANewSession`, `TestReceiverV3SupersededBaseDoneFailsWithoutAnAck` (`core/recovery/receiver_install_format_v3_test.go`) | `WALFormat` handle and BASE configs (claude05 R17c, pending) | 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-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 |
|
||||
@@ -306,7 +306,7 @@ Notes:
|
||||
- `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-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. The seam signature `BeginBaseInstall(baseLSN, installID)`, the receiver and legacy callers, the chunk-layer generation bump and `SeedChunkFrontier` are row 9b and row 10; the installing reopen, the fence before a resume or superseding begin, and the same-ID resume rule are row 11. A begin while installed is refused until retirement (8.5 has no installed -> installing edge).
|
||||
- `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`). The legacy single-lane caller is row 10. 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; the v3 `SeedChunkFrontier` is not wired yet; the installing reopen, the fence before a resume or superseding begin, and the same-ID resume rule are row 11. A begin while installed is refused until retirement (8.5 has no installed -> installing edge).
|
||||
- `INV-WAL-V3-W-001`, `INV-WAL-V3-FENCE-001`: Format bump v3, plan rows 5 and 5b (DESIGN r15 sections 6.1 to 6.6). Since 5b the v3 format runs inside the real `WALStore`, through the shared committer, dirty map, flusher and leaf. It is reachable only through `createWALStoreV3ForTest`/`openWALStoreV3ForTest`. Without the row-7 map candidate the v3 checkpoint and tail do not advance. They are STUBs until activation (row 12b). The test "crash" closes the file without further writes, so the slot-before-records reordering that mode C's lagged W guards against is covered by the composed model (claude05), not by these tests. Installing recovery is row 11.
|
||||
- `INV-WAL-V3-PUBLISH-001`: Format bump v3, plan row 3 (DESIGN r15 sections 4, 5 and 5.1). It is a STUB until the v3 store is wired in (rows 4 and 5) and activated (row 12b). The v2 checkpoint path (`persistCheckpointReleasing`) is unchanged and is retired in row 14a. The map coverage predicates against the root are added by row 7, and the conditions on BASE edges by rows 9 to 11.
|
||||
- `INV-WAL-V3-DESCRIPTOR-001`: Format bump v3, plan row 1 (DESIGN r15 section 2). It is a STUB until the activation commit (plan row 12b): no production open or create path reaches the v3 codec before then. The map-dependency checks (root and pages present and hash-valid) are added by plan row 7. The tests decode vectors from an independent generator (`core/storage/testdata/format_v3/slot/gen_slot_vectors.py`).
|
||||
|
||||
Reference in new issue
Block a user