mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
feat(storage): own maps before opening dark v3 stores
This commit is contained in:
1 parent
978b6f8e48
commit
dcc214e2d8
8 files changed
+340
-19
No files matched your search
@@ -4,7 +4,10 @@ package storage
|
||||
// integration: the row-5b real WALStore must call the lifecycle invalidations
|
||||
// and prepare from its permitted quiesced mutation snapshot before activation.
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"math"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
@@ -157,3 +160,39 @@ func (p *descriptorPublisherV3) invalidateMapProofV3() error {
|
||||
}
|
||||
return p.mapDomain.invalidateV3()
|
||||
}
|
||||
|
||||
// openDescriptorMapV3 validates geometry from the root and both valid slot
|
||||
// dependencies before any store background worker is started. Geometry is
|
||||
// subsequently checked by the chunk/provider caller against its configuration.
|
||||
func openDescriptorMapV3(path string, selected descriptorV3, fallback *descriptorV3) (*chunkLSNMapV3, *chunkMapCandidateV3, error) {
|
||||
if selected.MapRootLocator > math.MaxInt64-64 {
|
||||
return nil, nil, ErrMapInvalid
|
||||
}
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
var raw [8]byte
|
||||
_, err = f.ReadAt(raw[:], int64(selected.MapRootLocator)+56)
|
||||
err = errors.Join(err, f.Close())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
cb := binary.LittleEndian.Uint64(raw[:])
|
||||
m, c, err := openChunkLSNMapV3(path, selected, cb)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if fallback != nil {
|
||||
if fallback.UUID != selected.UUID || fallback.MapLineage != selected.MapLineage || !sameGeometryV3(*fallback, selected) {
|
||||
err = ErrMapInvalid
|
||||
} else {
|
||||
_, _, err = readChunkLSNMapV3(m.fd, *fallback, cb)
|
||||
}
|
||||
if err != nil {
|
||||
_ = m.Close()
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
return m, c, nil
|
||||
}
|
||||
@@ -273,7 +273,7 @@ func openInitializedWithMetadata(path string, f *os.File, sb *superblock, metada
|
||||
// openInitializedInternal is openInitializedWithMetadata with an optional
|
||||
// init hook that runs before the committer and flusher goroutines start
|
||||
// (the v3 store attaches its state there).
|
||||
func openInitializedInternal(path string, f *os.File, sb *superblock, metadata BlockMetadata, init func(*WALStore)) (*WALStore, error) {
|
||||
func openInitializedInternal(path string, f *os.File, sb *superblock, metadata BlockMetadata, init func(*WALStore) error) (*WALStore, error) {
|
||||
dm := newDirtyMap(64) // 64 shards is plenty for Phase 07 demo workloads
|
||||
|
||||
s := &WALStore{
|
||||
@@ -302,7 +302,9 @@ func openInitializedInternal(path string, f *os.File, sb *superblock, metadata B
|
||||
}
|
||||
s.syncExtentFile = f.Sync
|
||||
if init != nil {
|
||||
init(s)
|
||||
if err := init(s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
committer := NewGroupCommitter(GroupCommitterConfig{
|
||||
SyncFunc: s.syncWALBatch,
|
||||
@@ -1520,6 +1522,12 @@ func (s *WALStore) Close() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if s.v3 != nil && s.v3.ownedMap != nil {
|
||||
if err := s.v3.ownedMap.Close(); err != nil {
|
||||
closeErrors = append(closeErrors, err)
|
||||
}
|
||||
s.v3.ownedMap = nil
|
||||
}
|
||||
if s.fd != nil {
|
||||
closeErr := s.fd.Close()
|
||||
s.fd = nil
|
||||
|
||||
@@ -2,7 +2,6 @@ package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
@@ -15,7 +14,7 @@ func TestWALStoreV3_FlushedProgressRetriesAfterLaterSync(t *testing.T) {
|
||||
crash := func() { once.Do(func() { crashRecoveryHardeningStore(t, s) }) }
|
||||
t.Cleanup(crash) // own the file/committer even when setup or an assertion fails
|
||||
d := s.v3.pub.current()
|
||||
m, err := createChunkLSNMapV3(filepath.Join(t.TempDir(), "map"), d, 1)
|
||||
m, err := createChunkLSNMapV3(path+".chunkmap", d, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Actual store opener, not a manual bind after open. Bootstrap is explicit
|
||||
// because this RED also runs before the automatic mapped creator exists.
|
||||
func TestWALStoreV3_OpenRequiresBothMapGenerations(t *testing.T) {
|
||||
for _, fault := range []string{"none", "missing", "fallback_page", "zero_root"} {
|
||||
t.Run(fault, func(t *testing.T) {
|
||||
s, path := newStoreV3(t, WModeStrict)
|
||||
crashed := false
|
||||
t.Cleanup(func() {
|
||||
if !crashed {
|
||||
crashRecoveryHardeningStore(t, s)
|
||||
}
|
||||
})
|
||||
d := s.v3.pub.current()
|
||||
m, err := createChunkLSNMapV3(path+".chunkmap", d, 4)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mapClosed := false
|
||||
t.Cleanup(func() {
|
||||
if !mapClosed {
|
||||
m.Close()
|
||||
}
|
||||
})
|
||||
entries := make([]chunkLSNEntryV3, 16)
|
||||
for i := range entries {
|
||||
entries[i].Unknown = true
|
||||
}
|
||||
old, err := m.Prepare(2, 0, entries, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = s.v3.pub.publish(&s.mu, nil, func(n *descriptorV3) error { *n = old.descriptor(*n); return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
entries[0].LSN = 1 // force a distinct immutable page in the newer generation
|
||||
next, err := m.Prepare(3, 0, entries, old)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = s.v3.pub.publish(&s.mu, nil, func(n *descriptorV3) error { *n = next.descriptor(*n); return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fault == "fallback_page" {
|
||||
if _, err = m.fd.WriteAt([]byte{0xff}, int64(old.refs[0].Offset)+64); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = m.fd.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if fault == "zero_root" {
|
||||
d = s.v3.pub.current()
|
||||
d.MapRootHash = [32]byte{}
|
||||
if _, err = s.fd.WriteAt(d.encode(), int64(s.v3.pub.curSlot)*4096); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = s.fd.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err = m.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mapClosed = true
|
||||
if fault == "missing" {
|
||||
if err = os.Remove(path + ".chunkmap"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
crashRecoveryHardeningStore(t, s)
|
||||
crashed = true
|
||||
before, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mapBefore, mapBeforeErr := os.ReadFile(path + ".chunkmap")
|
||||
r, err := openWALStoreV3ForTest(path)
|
||||
if r != nil {
|
||||
r.DisableAutoFlushForRecoveryTest()
|
||||
t.Cleanup(func() { r.Close() })
|
||||
}
|
||||
if fault != "none" {
|
||||
after, e := os.ReadFile(path)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if !bytes.Equal(before, after) {
|
||||
t.Error("failed map open changed the store file")
|
||||
}
|
||||
mapAfter, mapAfterErr := os.ReadFile(path + ".chunkmap")
|
||||
if !bytes.Equal(mapBefore, mapAfter) || os.IsNotExist(mapBeforeErr) != os.IsNotExist(mapAfterErr) {
|
||||
t.Error("failed map open changed sidecar state")
|
||||
}
|
||||
if fault == "missing" && !os.IsNotExist(err) {
|
||||
t.Errorf("missing map error=%v", err)
|
||||
}
|
||||
if fault != "missing" && !errors.Is(err, ErrMapInvalid) {
|
||||
t.Errorf("corrupt map error=%v", err)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("store open accepted %s map dependency", fault)
|
||||
}
|
||||
if r != nil {
|
||||
t.Error("failed map open returned a store")
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r.v3.pub.mapDomain == nil || r.v3.pub.mapCurrent == nil {
|
||||
t.Fatal("store open did not automatically bind its durable map")
|
||||
}
|
||||
if _, err = r.Recover(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWALStoreV3_MappedCreateOpenOwnsMap(t *testing.T) {
|
||||
path := t.TempDir() + "/mapped"
|
||||
s, err := createMappedWALStoreV3ForTest(path, 65, 4096, v3TestWAL, WModeStrict, 4)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.DisableAutoFlushForRecoveryTest()
|
||||
closed := false
|
||||
t.Cleanup(func() {
|
||||
if !closed {
|
||||
s.Close()
|
||||
}
|
||||
})
|
||||
if s.v3.ownedMap == nil || s.v3.pub.mapDomain == nil {
|
||||
t.Fatal("created store has no owned map/proof")
|
||||
}
|
||||
es, _, err := readChunkLSNMapV3(s.v3.ownedMap.fd, s.v3.pub.current(), 4)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(es) != 17 {
|
||||
t.Fatalf("clipped geometry entries=%d want17", len(es))
|
||||
}
|
||||
for _, e := range es {
|
||||
if !e.Unknown || e.LSN != 0 {
|
||||
t.Fatal("initial map is not conservative UNKNOWN")
|
||||
}
|
||||
}
|
||||
oldDomain := s.v3.pub.mapDomain
|
||||
mapFD := s.v3.ownedMap.fd
|
||||
if err = s.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
closed = true
|
||||
if _, err = mapFD.Stat(); err == nil {
|
||||
t.Fatal("store Close leaked owned sidecar")
|
||||
}
|
||||
r, err := openWALStoreV3ForTest(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.DisableAutoFlushForRecoveryTest()
|
||||
t.Cleanup(func() { r.Close() })
|
||||
if r.v3.pub.mapDomain == nil || r.v3.pub.mapDomain == oldDomain {
|
||||
t.Fatal("reopen did not create a fresh proof domain")
|
||||
}
|
||||
if _, err = r.Recover(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -283,6 +283,12 @@ func TestWALStoreRecoverReconstructsLegacyWrappedRetainedWindow(t *testing.T) {
|
||||
func crashRecoveryHardeningStore(t *testing.T, s *WALStore) {
|
||||
t.Helper()
|
||||
s.committer.Stop()
|
||||
if s.v3 != nil && s.v3.ownedMap != nil {
|
||||
if err := s.v3.ownedMap.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.v3.ownedMap = nil
|
||||
}
|
||||
if err := s.fd.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ import (
|
||||
// install paths (ApplyEntry, WriteExtentDirect, AdvanceFrontier; rows 9 to
|
||||
// 11) and the checkpoint/tail advance, which needs the row-7 map candidate.
|
||||
type walStoreV3State struct {
|
||||
pub *descriptorPublisherV3
|
||||
w *walWriterV3
|
||||
pub *descriptorPublisherV3
|
||||
w *walWriterV3
|
||||
ownedMap *chunkLSNMapV3
|
||||
|
||||
appended atomic.Uint64 // highest LSN pwritten to the WAL
|
||||
wack atomic.Uint64 // highest acknowledged LSN (Sync completed)
|
||||
@@ -103,6 +104,18 @@ func createWALStoreV3ForTest(path string, numBlocks uint32, blockSize uint32, wa
|
||||
// logical cursor (tail = head) starting at cursor, to exercise the last
|
||||
// representable cursors.
|
||||
func createWALStoreV3AtCursorForTest(path string, numBlocks uint32, blockSize uint32, walSize uint64, mode WMode, cursor uint64) (*WALStore, error) {
|
||||
return createWALStoreV3MapAtCursorForTest(path, numBlocks, blockSize, walSize, mode, cursor, 0)
|
||||
}
|
||||
|
||||
// Explicit geometry selector for dark row7 caller controls. Zero is reserved
|
||||
// for earlier unmapped row5 fixtures; production activation must never use it.
|
||||
func createMappedWALStoreV3ForTest(path string, numBlocks, blockSize uint32, walSize uint64, mode WMode, chunkBlocks uint64) (*WALStore, error) {
|
||||
if chunkBlocks == 0 {
|
||||
return nil, ErrMapInvalid
|
||||
}
|
||||
return createWALStoreV3MapAtCursorForTest(path, numBlocks, blockSize, walSize, mode, 0, chunkBlocks)
|
||||
}
|
||||
func createWALStoreV3MapAtCursorForTest(path string, numBlocks, blockSize uint32, walSize uint64, mode WMode, cursor, chunkBlocks uint64) (*WALStore, error) {
|
||||
d := descriptorV3{
|
||||
ImplKind: ImplKindWALStore, ImplVersion: walStoreImplVersion3,
|
||||
VolumeSize: uint64(numBlocks) * uint64(blockSize), ExtentSize: 64 * 1024, BlockSize: blockSize,
|
||||
@@ -123,6 +136,29 @@ func createWALStoreV3AtCursorForTest(path string, numBlocks uint32, blockSize ui
|
||||
return nil, err
|
||||
}
|
||||
err = fd.Truncate(int64(d.WALOffset + d.WALSize + d.VolumeSize))
|
||||
if err == nil && chunkBlocks != 0 {
|
||||
var m *chunkLSNMapV3
|
||||
m, err = createChunkLSNMapV3(path+".chunkmap", d, chunkBlocks)
|
||||
if err == nil {
|
||||
shape, e := mapShapeForV3(d, chunkBlocks)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else if shape.chunks > uint64(int(^uint(0)>>1))/16 {
|
||||
err = ErrMapInvalid
|
||||
} else {
|
||||
entries := make([]chunkLSNEntryV3, int(shape.chunks))
|
||||
for i := range entries {
|
||||
entries[i].Unknown = true
|
||||
}
|
||||
var c *chunkMapCandidateV3
|
||||
c, err = m.Prepare(1, 0, entries, nil)
|
||||
if err == nil {
|
||||
d = c.descriptor(d)
|
||||
}
|
||||
}
|
||||
err = errors.Join(err, m.Close())
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
_, err = fd.WriteAt(d.encode(), slotAOffsetV3)
|
||||
}
|
||||
@@ -135,7 +171,12 @@ func createWALStoreV3AtCursorForTest(path string, numBlocks uint32, blockSize ui
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s, err := openWALStoreV3ForTest(path)
|
||||
var s *WALStore
|
||||
if chunkBlocks == 0 {
|
||||
s, err = openUnmappedWALStoreV3ForTest(path)
|
||||
} else {
|
||||
s, err = openWALStoreV3ForTest(path)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -149,6 +190,15 @@ func createWALStoreV3AtCursorForTest(path string, numBlocks uint32, blockSize ui
|
||||
// openWALStoreV3ForTest opens a v3 file WITHOUT recovering it, like
|
||||
// OpenWALStore: call Recover before any Read or Write.
|
||||
func openWALStoreV3ForTest(path string) (*WALStore, error) {
|
||||
return openWALStoreV3MapInternalForTest(path, true)
|
||||
}
|
||||
|
||||
// Only pre-row7 dark fixtures can opt out of requiring a map. Even these
|
||||
// fixtures must validate a non-placeholder root; production has no opt-out.
|
||||
func openUnmappedWALStoreV3ForTest(path string) (*WALStore, error) {
|
||||
return openWALStoreV3MapInternalForTest(path, false)
|
||||
}
|
||||
func openWALStoreV3MapInternalForTest(path string, requireMap bool) (*WALStore, error) {
|
||||
f, err := os.OpenFile(path, os.O_RDWR, 0o644)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("storage: open %s: %w", path, err)
|
||||
@@ -174,6 +224,17 @@ func openWALStoreV3ForTest(path string) (*WALStore, error) {
|
||||
if od, oerr := decodeSlotV3(otherRaw, nil); oerr == nil && od.MigrationPhase == MigrationNormal {
|
||||
other = &od
|
||||
}
|
||||
var ownedMap *chunkLSNMapV3
|
||||
var mapCurrent *chunkMapCandidateV3
|
||||
// Earlier dark row5 fixtures have no map tuple. A real immutable root is
|
||||
// never optional: missing metadata is not a clean map.
|
||||
if requireMap || d.MapRootHash != [32]byte{} {
|
||||
ownedMap, mapCurrent, err = openDescriptorMapV3(path+".chunkmap", d, other)
|
||||
if err != nil {
|
||||
_ = f.Close()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
// The shared store reads its geometry from sb; WAL bounds and the
|
||||
// checkpoint come from the selected descriptor.
|
||||
sb := superblock{
|
||||
@@ -183,8 +244,7 @@ func openWALStoreV3ForTest(path string) (*WALStore, error) {
|
||||
CreatedAt: d.CreatedAt, ImplKind: d.ImplKind, ImplVersion: d.ImplVersion,
|
||||
}
|
||||
copy(sb.Magic[:], superblockMagic)
|
||||
var initErr error
|
||||
s, err := openInitializedInternal(path, f, &sb, nil, func(s *WALStore) {
|
||||
s, err := openInitializedInternal(path, f, &sb, nil, func(s *WALStore) error {
|
||||
v := &walStoreV3State{}
|
||||
v.pub = newDescriptorPublisherV3(d, id, other, descriptorIOV3{
|
||||
writeSlot: func(off int64, buf []byte) error {
|
||||
@@ -206,21 +266,26 @@ func openWALStoreV3ForTest(path string) (*WALStore, error) {
|
||||
})
|
||||
w, err := newWALWriterV3(f, v.pub)
|
||||
if err != nil {
|
||||
initErr = err
|
||||
return
|
||||
return err
|
||||
}
|
||||
v.w = w
|
||||
v.wack.Store(d.W)
|
||||
if ownedMap != nil {
|
||||
if err := v.pub.bindMapV3(mapCurrent, newMapProofEpochV3()); err != nil {
|
||||
return err
|
||||
}
|
||||
v.ownedMap = ownedMap
|
||||
}
|
||||
s.v3 = v
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
if ownedMap != nil {
|
||||
_ = ownedMap.Close()
|
||||
}
|
||||
_ = f.Close()
|
||||
return nil, err
|
||||
}
|
||||
if initErr != nil {
|
||||
_ = s.Close()
|
||||
return nil, initErr
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func newStoreV3(t *testing.T, mode WMode) (*WALStore, string) {
|
||||
// reopenV3 opens and recovers, as a restart would.
|
||||
func reopenV3(t *testing.T, path string) (*WALStore, error) {
|
||||
t.Helper()
|
||||
s, err := openWALStoreV3ForTest(path)
|
||||
s, err := openUnmappedWALStoreV3ForTest(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -919,7 +919,32 @@ func TestWALStoreV3FlusherCheckpointIsClampedToTheAcknowledgedW(t *testing.T) {
|
||||
var crashOnce sync.Once
|
||||
crash := func() { crashOnce.Do(func() { crashRecoveryHardeningStore(t, s) }) }
|
||||
t.Cleanup(crash)
|
||||
s.v3.mapCandidate = stubMapCandidateV3
|
||||
m, err := createChunkLSNMapV3(path+".chunkmap", s.v3.pub.current(), 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { m.Close() })
|
||||
entries := make([]chunkLSNEntryV3, s.NumBlocks())
|
||||
for i := range entries {
|
||||
entries[i].Unknown = true
|
||||
}
|
||||
initial, err := m.Prepare(s.v3.pub.current().MapGeneration+1, 0, entries, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = s.v3.pub.publish(&s.mu, nil, func(d *descriptorV3) error { *d = initial.descriptor(*d); return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = s.v3.pub.publish(&s.mu, nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.v3.mapCandidate = func(cp uint64) (func(*descriptorV3) error, error) {
|
||||
c, e := m.Prepare(s.v3.pub.current().MapGeneration+1, cp, entries, nil)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
return func(d *descriptorV3) error { *d = c.descriptor(*d); return nil }, nil
|
||||
}
|
||||
writeSynced(t, s, 1, 1) // acknowledged W 1
|
||||
if _, err := s.Write(2, blk(2)); err != nil { // dirty, unsynced
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -282,7 +282,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-WAL-V3-RECORD-001` | A dark 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 codec only; no production transition yet) | `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 dark 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 (dark append only) | `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-BINDING-001` | The dark v3 writer stamps the selected nonce and absolute cursor, fits each append/padding inside the dual-slot reuse floor, and refuses later I/O after a pwrite failure. A dark scanner checks nonce and exact expected cursor before using Length/count, checks the full record again, skips only geometric end slack, and stops at the first untrusted record without payload resynchronization. It returns a typed scan result, never ACK or serving permission. | M1 Recovering (dark muscles only) | `core/storage/wal_io_v3.go` `append`, `scanWALV3`, `walSnapshotV3` | `TestWALIOV3_RealWriterReopenScan`, `TestWALIOV3_WrapPaddingAndSlack`, `TestWALIOV3_StopsAtBindingBeforeEmbeddedRecord`, `TestWALIOV3_EmbeddedRecordInPayloadIsNotScanned`, `TestWALIOV3_InstalledScanBeginsAtMaxTail`, `TestWALIOV3_FloorAndPwriteFailureRefuse` | Record/lap admission is abstracted in composed WALFormatR5; physical framing/wrap boundaries remain code-test obligations | STUB |
|
||||
| `INV-WAL-V3-MAP-PUBLISH-001` | After a dark publisher binds a validated map, every publication carries a matching immutable tuple with merged checkpoint <= C <= merged W. A prepared replacement needs a higher generation, non-regressing coverage and the same sidecar/open proof domain with unchanged epoch/mutation token. Stale candidates write no slot; W-only rollover carries the current root; unknown slot outcomes pin dependencies. | M1 (dark map publication only; checkpoint/capture caller wiring pending) | `core/storage/chunk_map_publication_v3.go`; `core/storage/descriptor_v3.go` `publishLockedWithMapV3` | `TestMapPublicationV3_BindValidatesBothSlotDependencies`, `TestMapPublicationV3_HeldPublicationsBothOrders`, `TestMapPublicationV3_IsolatedMergedCoverageAndWPositive`, `TestMapPublicationV3_ProofEpochAndMutationRefusal`, `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestMapPublicationV3_CoverageWAndNoUnpreparedRoot`, `TestMapPublicationV3_ProofChangedDuringPersistenceRefuses`; `TestWALStoreV3_RealRecoverInvalidatesMapProofAtStartAndEnd`, `TestWALStoreV3_FailedRecoverInvalidatesMapProofAtBothBoundaries` | WALFormatR5 map coverage / volatile proof epoch; physical caller wiring remains a code obligation | STUB |
|
||||
| `INV-WAL-V3-MAP-PUBLISH-001` | After a dark publisher binds a validated map, every publication carries a matching immutable tuple with merged checkpoint <= C <= merged W. A prepared replacement needs a higher generation, non-regressing coverage and the same sidecar/open proof domain with unchanged epoch/mutation token. Stale candidates write no slot; W-only rollover carries the current root; unknown slot outcomes pin dependencies. | M1 (dark map publication only; checkpoint/capture caller wiring pending) | `core/storage/chunk_map_publication_v3.go`; `core/storage/descriptor_v3.go` `publishLockedWithMapV3` | `TestWALStoreV3_OpenRequiresBothMapGenerations`, `TestWALStoreV3_MappedCreateOpenOwnsMap`, `TestMapPublicationV3_BindValidatesBothSlotDependencies`, `TestMapPublicationV3_HeldPublicationsBothOrders`, `TestMapPublicationV3_IsolatedMergedCoverageAndWPositive`, `TestMapPublicationV3_ProofEpochAndMutationRefusal`, `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestMapPublicationV3_CoverageWAndNoUnpreparedRoot`, `TestMapPublicationV3_ProofChangedDuringPersistenceRefuses`; `TestWALStoreV3_RealRecoverInvalidatesMapProofAtStartAndEnd`, `TestWALStoreV3_FailedRecoverInvalidatesMapProofAtBothBoundaries` | WALFormatR5 map coverage / volatile proof epoch; physical caller wiring remains a code obligation | STUB |
|
||||
| `INV-WAL-V3-MAP-BYTES-001` | A dark v3 map candidate names immutable, owned, identity- and geometry-checked pages and root. Domain-separated body digests, reserved/unused bytes, exact page counts, file bounds and non-aliasing intervals all validate before entries escape. Persistence orders pages/fsync, root/fsync, directory fsync; a persistence-transaction error yields no candidate and latches subsequent I/O; preflight and Stat errors do not latch. Append-only retention preserves both slots and pending candidates. | M1 (dark map preparation only) | `core/storage/chunk_lsn_map_v3.go` `Prepare`, `readChunkLSNMapV3` | `TestChunkLSNMapV3_CanonicalVectors`, `TestChunkLSNMapV3_PersistReloadAndReuse`, `TestChunkLSNMapV3_CorruptionAndBounds`, `TestChunkLSNMapV3_FailureDoesNotPublishOrReuse`, `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage`, `TestChunkLSNMapV3_RejectsRehashedMalformedRecords`, `TestChunkLSNMapV3_EntryBoundBeforeRootIO`, `TestChunkLSNMapV3_WholePageHashIsNotBodyDigest`, `TestChunkLSNMapV3_PreflightErrorDoesNotLatch` | WALFormatR5 abstract map dependency; physical encoding/digest/order are code obligations | STUB |
|
||||
| `INV-WAL-V3-PUBLISH-001` | Every v3 descriptor change goes through one publisher. It writes the fallback slot with slotGen+1 under `descMu`. It takes `WALStore.mu` only to snapshot and releases it before slot I/O, and fsync is the leaf. It rebases onto the authoritative descriptor: W and the checkpoint are max-merged, and identity, geometry and nonce changes are refused, as are tail regression, a map root change without a higher generation and any BASE edge outside DESIGN 8.5 (installed -> installing is refused). A failed slot write (full or partial) or fsync publishes nothing. It latches the store fault inside the fsync leaf, before `fileSyncMu` is released, so a queued store Sync cannot acknowledge through it, keeps the uncertain candidate pinned and refuses every later publication, rollover and reuse until a reopen reads the slots back. A fault latched mid-flight is refused at the success boundary. A counter above 2^64-2 is refused with `ErrCounterExhausted` before any write. When the fallback slot pins reuse, a metadata-only rollover advances the floor, and no floor is ever computed across nonces. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `publish`, `mergeDescriptorV3`, `baseTransitionAllowedV3`, `rolloverIfPinned`, `reuseFloor` | `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestDescriptorV3MergeIsMonotonicAndRefusesForbiddenChanges`, `TestDescriptorV3ConcurrentPublishersNeverRegress`, `TestDescriptorV3LockOrderRecorder`, `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3FaultLatchedDuringPublicationRefusesAtSuccessBoundary`, `TestDescriptorV3FullRingRolloverAdvancesTheFloorWithoutAnyChange`, `TestDescriptorV3RolloverFsyncFailureKeepsTheFloorPinned`, `TestDescriptorV3MixedNoncesNeverYieldAReuseFloor`, `TestDescriptorV3BaseTransitionTable`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestDescriptorV3PublicationCounterExhaustion`, `TestDescriptorV3QueuedStoreSyncCannotAckAfterSlotWriteError` (`core/storage/descriptor_v3_test.go`) | — | STUB |
|
||||
| `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` | `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 |
|
||||
@@ -294,7 +294,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
Notes:
|
||||
|
||||
- `INV-WAL-V3-LSN-ORDER-001`: the writer gate prevents an out-of-order physical chain whose dropped unacked middle record could later resurrect. Raw scanner/recovery integrity verdicts and the v3 ApplyEntry superseded-no-op/refusal policy are separate caller obligations. Legacy ApplyEntry and production v2 behavior are unchanged.
|
||||
- `INV-WAL-V3-MAP-PUBLISH-001`: The open/quiesced bind validates the selected and every valid fallback map root/page dependency before installing a proof domain, with a slot snapshot recheck after I/O. A corrupt fallback refuses binding even if the selected map is intact; validation writes no slots and preserves the prior domain on failure. This is a binding seam control, not automatic create/open or capture wiring. Real Recover START and END invalidation is wired and controlled on success and WAL-integrity failure, with a durable map manually bound to the actual store publisher. Automatic map attach, reset/install transitions and checkpoint/capture/provider wiring still require integration. Existing dark lifecycle tests drive invalidation primitives; only the two explicitly named real-store controls exercise actual Recover, and none claims flusher or provider coverage. The owner serializes lifecycle transitions with publication using its existing lifecycle admission. No new lock or callback is taken under descMu; validation uses immutable candidate fields and atomic proof loads.
|
||||
- `INV-WAL-V3-MAP-PUBLISH-001`: The open/quiesced bind validates the selected and every valid fallback map root/page dependency before installing a proof domain, with a slot snapshot recheck after I/O. A corrupt fallback refuses binding even if the selected map is intact; validation writes no slots and preserves the prior domain on failure. This is a binding seam control, not automatic create/open or capture wiring. Real Recover START and END invalidation is wired and controlled on success and WAL-integrity failure, with a durable map manually bound to the actual store publisher. The dark map-requiring actual-store opener now loads its owned sidecar and validates both slots before workers start, binds a fresh proof domain, and Close releases the map. The explicit mapped creator persists an all-UNKNOWN initial map before publishing its first slot. Earlier unmapped row5 fixtures have a separately named test-only opt-out, not a production selector. Reset/install transitions and checkpoint/capture/provider wiring still require integration. Existing dark lifecycle tests drive invalidation primitives; only the two explicitly named real-store controls exercise actual Recover, and none claims flusher or provider coverage. The owner serializes lifecycle transitions with publication using its existing lifecycle admission. No new lock or callback is taken under descMu; validation uses immutable candidate fields and atomic proof loads.
|
||||
|
||||
- `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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user