mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
Merge remote-tracking branch 'origin/main' into feat/v4b-record-pages
This commit is contained in:
commit
44967d1b30
3 files changed
+511
No files matched your search
@@ -0,0 +1,194 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/chunkkernel"
|
||||
)
|
||||
|
||||
// coverageArg is the kernel's argument for a coverage.
|
||||
func coverageArg(c LocalCoverage) chunkkernel.Arg {
|
||||
switch c {
|
||||
case CoverageAll:
|
||||
return chunkkernel.Arg{Value: "all"}
|
||||
case CoverageSome:
|
||||
return chunkkernel.Arg{Value: "some"}
|
||||
}
|
||||
return chunkkernel.Arg{Value: "none"}
|
||||
}
|
||||
|
||||
// legacyPresence is a v1.0.x presence file: the chunks it calls absent and
|
||||
// the blocks of absent chunks it calls local.
|
||||
type legacyPresence struct {
|
||||
absent map[uint64]bool
|
||||
local map[uint64]bool
|
||||
}
|
||||
|
||||
func readLegacyPresence(path string) (legacyPresence, error) {
|
||||
p := legacyPresence{absent: map[uint64]bool{}, local: map[uint64]bool{}}
|
||||
data, err := os.ReadFile(path)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return p, nil
|
||||
}
|
||||
if err != nil {
|
||||
return p, fmt.Errorf("storage: chunk presence: %w", err)
|
||||
}
|
||||
sc := bufio.NewScanner(bytes.NewReader(data))
|
||||
for sc.Scan() {
|
||||
kind, num, ok := strings.Cut(sc.Text(), " ")
|
||||
n, perr := strconv.ParseUint(num, 10, 64)
|
||||
if !ok || perr != nil || (kind != "absent" && kind != "local") {
|
||||
return p, fmt.Errorf("storage: chunk presence: bad line %q", sc.Text())
|
||||
}
|
||||
if kind == "absent" {
|
||||
p.absent[n] = true
|
||||
} else {
|
||||
p.local[n] = true
|
||||
}
|
||||
}
|
||||
return p, sc.Err()
|
||||
}
|
||||
|
||||
func chunkPresencePath(storePath string) string { return storePath + ".chunkpresence" }
|
||||
|
||||
// ErrChunkRecordOtherEpoch refuses an upgrade of a store already marked at
|
||||
// another local-work epoch: that store belongs to the attach after a move.
|
||||
var ErrChunkRecordOtherEpoch = errors.New("storage: chunk record: store marked at another local-work epoch")
|
||||
|
||||
// errPresenceAfterMarker: the presence file is never a seed once the store is
|
||||
// marked; reaching the seed then is a defect.
|
||||
var errPresenceAfterMarker = errors.New("storage: chunk record: the presence file is not evidence after the marker")
|
||||
|
||||
// upgradeChunkRecord is the one-way upgrade of a v1.0.x volume's per-chunk
|
||||
// state, at open: after Recover and Sync, with extent draining held, before
|
||||
// the chunk layer attaches. It reads no chunk data. In order:
|
||||
//
|
||||
// 1. the seed: a chunk the presence file calls present is wholly local; an
|
||||
// absent one has the blocks the file calls local plus those of log
|
||||
// entries not yet applied to the extent (the legacy layer would mark them
|
||||
// local when they are applied);
|
||||
// 2. the store persists the bitmap and hands back its prepared coverage; the
|
||||
// pages are written from it, each chunk classified by the kernel's
|
||||
// Rebuilt event (none: absent, some: partial, all: hash unknown);
|
||||
// 3. the store publishes the bitmap and fences both descriptor slots;
|
||||
// 4. the record's header (completeChunkRecord: pages current with the
|
||||
// store, G its synced position);
|
||||
// 5. the presence file is removed.
|
||||
//
|
||||
// Each step can be repeated.
|
||||
//
|
||||
// THE PRESENCE FILE IS EVIDENCE ONLY BEFORE THE MARKER. Once the store is
|
||||
// marked, its bitmap is the durable fact and a missing presence file would
|
||||
// read as "nothing absent": absent chunks would serve local bytes never
|
||||
// fetched. So: a store marked at this epoch is never seeded from the file; a
|
||||
// complete record only has the file removed, an incomplete one gets its pages
|
||||
// again from the store's bitmap (the same-epoch retry of the store's boundary,
|
||||
// which takes no seed). A store marked at another epoch is refused. Only an
|
||||
// unmarked store is seeded from the presence file.
|
||||
func upgradeChunkRecord(ctx context.Context, s *WALStore, epoch uint64) error {
|
||||
cb := s.ChunkBlocks()
|
||||
if cb == 0 {
|
||||
return errors.New("storage: chunk record upgrade needs an owned chunk map")
|
||||
}
|
||||
chunks := (uint64(s.NumBlocks()) + cb - 1) / cb
|
||||
dir, presence := chunkRecordDir(s.path), chunkPresencePath(s.path)
|
||||
prepare := func(r ChunkCoverageReader) error {
|
||||
pos, _, _ := s.Boundaries()
|
||||
return writeChunkRecordPagesFrom(dir, chunks, pos, r)
|
||||
}
|
||||
if marked, e := s.ChunkStateMarker(); marked {
|
||||
if e != epoch {
|
||||
return fmt.Errorf("%w: marked %d, upgrade asked at %d", ErrChunkRecordOtherEpoch, e, epoch)
|
||||
}
|
||||
pos, _, _ := s.Boundaries()
|
||||
got, err := loadChunkRecord(dir, chunks, marked, e, pos)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !got.Complete {
|
||||
noSeed := func(uint64, uint64) (ChunkCoverageSeed, error) { return ChunkCoverageSeed{}, errPresenceAfterMarker }
|
||||
if err := s.InitializeChunkCoverage(ctx, epoch, noSeed, prepare); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := completeChunkRecord(s, dir, epoch, chunks); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return removeLegacyPresence(presence)
|
||||
}
|
||||
legacy, err := readLegacyPresence(presence)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.ScanLBAs(s.CheckpointLSN()+1, func(e RecoveryEntry) error {
|
||||
if legacy.absent[uint64(e.LBA)/cb] {
|
||||
legacy.local[uint64(e.LBA)] = true
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("storage: chunk record upgrade: log suffix: %w", err)
|
||||
}
|
||||
seed := func(chunk, blocks uint64) (ChunkCoverageSeed, error) {
|
||||
if !legacy.absent[chunk] {
|
||||
return ChunkCoverageSeed{All: true}, nil
|
||||
}
|
||||
var local []uint64
|
||||
for b := uint64(0); b < blocks; b++ {
|
||||
if legacy.local[chunk*cb+b] {
|
||||
local = append(local, b)
|
||||
}
|
||||
}
|
||||
return ChunkCoverageSeed{Blocks: local}, nil
|
||||
}
|
||||
if err := s.InitializeChunkCoverage(ctx, epoch, seed, prepare); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := completeChunkRecord(s, dir, epoch, chunks); err != nil {
|
||||
return err
|
||||
}
|
||||
return removeLegacyPresence(presence)
|
||||
}
|
||||
|
||||
// writeChunkRecordPagesFrom writes every page, valid through pos, with each
|
||||
// chunk's state from its coverage by the kernel's Rebuilt event.
|
||||
func writeChunkRecordPagesFrom(dir string, chunks, pos uint64, r ChunkCoverageReader) error {
|
||||
for seg := uint64(0); seg < chunkRecordSegments(chunks); seg++ {
|
||||
p := &chunkRecordPage{Segment: seg, ValidThrough: pos, Entries: make([]chunkRecordEntry, chunkRecordSegmentLen(chunks, seg))}
|
||||
for i := range p.Entries {
|
||||
chunk := seg*chunkRecordSegment + uint64(i)
|
||||
cov, _, err := r.Coverage(chunk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, _, err := chunkkernel.Step(chunkkernel.State{Kind: chunkkernel.Absent}, chunkkernel.Rebuilt, coverageArg(cov))
|
||||
if err != nil {
|
||||
return fmt.Errorf("storage: chunk record: chunk %d: %w", chunk, err)
|
||||
}
|
||||
if p.Entries[i].State, err = chunkRecordStateCode(res.State.Kind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := writeChunkRecordPage(dir, p); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeLegacyPresence(path string) error {
|
||||
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return fmt.Errorf("storage: chunk presence: remove: %w", err)
|
||||
}
|
||||
if err := syncDir(filepath.Dir(path)); err != nil {
|
||||
return fmt.Errorf("storage: chunk presence: fsync directory: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/chunkkernel"
|
||||
)
|
||||
|
||||
// legacyVolume builds a v1.0.x volume: 64 blocks of 4 in 16 chunks. Chunks
|
||||
// 2, 3 and 5 are absent in the presence file; chunk 2 has its block 9 (offset
|
||||
// 1) local there; chunk 3 gets block 13 from one log entry and blocks 14 and
|
||||
// 15 from a batch, none applied to the extent (above the checkpoint); its
|
||||
// block 12 is not local. Every other chunk is present.
|
||||
func legacyVolume(t *testing.T) string {
|
||||
t.Helper()
|
||||
s, path := newMappedCheckpointStoreV3(t)
|
||||
writeSynced(t, s, 1, 1)
|
||||
writeSynced(t, s, 9, 9)
|
||||
if err := s.flusher.flushOnce(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(chunkPresencePath(path), []byte("absent 2\nabsent 3\nabsent 5\nlocal 9\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
writeSynced(t, s, 13, 13) // in the log only
|
||||
if _, err := s.WriteBatch(14, [][]byte{blk(14), blk(15)}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crashStore(t, s)
|
||||
return path
|
||||
}
|
||||
|
||||
// openForUpgrade opens a store as the upgrade does: recovered, extent
|
||||
// draining held, no chunk layer.
|
||||
func openForUpgrade(t *testing.T, path string) *WALStore {
|
||||
t.Helper()
|
||||
s, err := openWALStoreV3MapInternalForTest(path, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.DisableAutoFlushForRecoveryTest()
|
||||
s.HoldExtentDrainUntilChunkLayer()
|
||||
t.Cleanup(func() { s.Close() })
|
||||
if _, err := s.Recover(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func recordKinds(t *testing.T, s *WALStore) []chunkkernel.Kind {
|
||||
t.Helper()
|
||||
marked, epoch := s.ChunkStateMarker()
|
||||
got, err := loadChunkRecord(chunkRecordDir(s.path), 16, marked, epoch, syncedPos(s))
|
||||
if err != nil || !got.Complete {
|
||||
t.Fatalf("record not complete: %+v %v", got, err)
|
||||
}
|
||||
var kinds []chunkkernel.Kind
|
||||
for _, e := range got.Pages[0].Entries {
|
||||
k, err := chunkRecordKind(e.State)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
kinds = append(kinds, k)
|
||||
}
|
||||
return kinds
|
||||
}
|
||||
|
||||
// wantLocal is each absent chunk's exact local offsets; every other chunk is
|
||||
// wholly local.
|
||||
var wantLocal = map[uint64][]uint64{2: {1}, 3: {1, 2, 3}, 5: nil}
|
||||
|
||||
// checkLocalBits pins the store's bitmap block by block.
|
||||
func checkLocalBits(t *testing.T, s *WALStore) {
|
||||
t.Helper()
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
for c := uint64(0); c < 16; c++ {
|
||||
e := s.v3.mapEntries[c]
|
||||
if e.Local == nil {
|
||||
t.Fatalf("chunk %d has no bitmap", c)
|
||||
}
|
||||
want, absent := wantLocal[c]
|
||||
for b := uint64(0); b < 4; b++ {
|
||||
local := !absent
|
||||
for _, w := range want {
|
||||
if w == b {
|
||||
local = true
|
||||
}
|
||||
}
|
||||
if got := e.Local.all || e.Local.has(b); got != local {
|
||||
t.Fatalf("chunk %d block %d local=%v, want %v", c, b, got, local)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkUpgradedKinds(t *testing.T, s *WALStore) {
|
||||
t.Helper()
|
||||
checkLocalBits(t, s)
|
||||
kinds := recordKinds(t, s)
|
||||
want := map[int]chunkkernel.Kind{2: chunkkernel.Partial, 3: chunkkernel.Partial, 5: chunkkernel.Absent}
|
||||
for c, k := range kinds {
|
||||
w, ok := want[c]
|
||||
if !ok {
|
||||
w = chunkkernel.Unknown // present: whole, hash unknown
|
||||
}
|
||||
if k != w {
|
||||
t.Fatalf("chunk %d is %s, want %s", c, k, w)
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(chunkPresencePath(s.path)); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("legacy presence still there: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A v1.0.x volume upgrades at open: present chunks whole and unknown, absent
|
||||
// ones partial with their local blocks (from the file and from the log not yet
|
||||
// applied) or absent; the record is complete and the presence file gone.
|
||||
func TestUpgradeChunkRecordFromLegacyPresence(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
checkUpgradedKinds(t, s)
|
||||
if c, _, err := s.Coverage(3); err != nil || c != CoverageSome {
|
||||
t.Fatalf("chunk 3 coverage %d %v: the log's block was lost", c, err)
|
||||
}
|
||||
}
|
||||
|
||||
// A crash before the store's fence, at its first descriptor slot write: the
|
||||
// pages are complete, the header absent, the presence file there; the next
|
||||
// open upgrades again.
|
||||
func TestUpgradeChunkRecordCrashBeforeTheFence(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
crash := errors.New("crash before the descriptor slots")
|
||||
writes := 0
|
||||
s.v3.testBeforeSlotWrite = func() error {
|
||||
writes++
|
||||
pages, bad, err := readChunkRecordPages(chunkRecordDir(path), 16)
|
||||
if err != nil || len(bad) != 0 || len(pages) != 1 || len(pages[0].Entries) != 16 {
|
||||
t.Errorf("at the first slot write the pages are not complete: %v %v", bad, err)
|
||||
}
|
||||
if _, err := os.Stat(chunkRecordDir(path) + "/" + chunkRecordHeaderName); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Errorf("header before the fence: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(chunkPresencePath(path)); err != nil {
|
||||
t.Errorf("presence gone before the fence: %v", err)
|
||||
}
|
||||
return crash
|
||||
}
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); !errors.Is(err, crash) {
|
||||
t.Fatalf("the upgrade answered %v, want the injected crash", err)
|
||||
}
|
||||
if writes != 1 {
|
||||
t.Fatalf("slot writes %d, want the first one only", writes)
|
||||
}
|
||||
crashStore(t, s)
|
||||
next := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), next, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
checkUpgradedKinds(t, next)
|
||||
}
|
||||
|
||||
// A crash after the fence and before the header: both slots marked, no
|
||||
// header, the presence file there; the next open completes from the store's
|
||||
// bitmap.
|
||||
func TestUpgradeChunkRecordCrashAfterTheFence(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
header := chunkRecordDir(path) + "/" + chunkRecordHeaderName
|
||||
if err := os.MkdirAll(header, 0o755); err != nil { // the header's write fails
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); err == nil {
|
||||
t.Fatal("the control needs a failed header write")
|
||||
}
|
||||
for _, off := range []int64{slotAOffsetV3, slotBOffsetV3} {
|
||||
raw := make([]byte, slotSizeV3)
|
||||
if _, err := s.fd.ReadAt(raw, off); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if d, err := decodeSlotV3(raw, nil); err != nil || d.ChunkStateFormat != 1 || d.LocalWorkEpoch != 7 {
|
||||
t.Fatalf("slot %d not fenced before the header: %+v %v", off, d, err)
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(chunkPresencePath(path)); err != nil {
|
||||
t.Fatalf("presence gone before the header: %v", err)
|
||||
}
|
||||
crashStore(t, s)
|
||||
if err := os.Remove(header); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), next, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
checkUpgradedKinds(t, next)
|
||||
}
|
||||
|
||||
// A crash after the header and before the presence file is removed: the next
|
||||
// open finds the record complete and only removes the file: no page, no
|
||||
// header and no descriptor slot is written.
|
||||
func TestUpgradeChunkRecordCrashAfterTheHeader(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crashStore(t, s)
|
||||
if err := os.WriteFile(chunkPresencePath(path), []byte("absent 2\n"), 0o644); err != nil {
|
||||
t.Fatal(err) // as if the removal had not happened
|
||||
}
|
||||
type recordFile struct {
|
||||
bytes string
|
||||
info os.FileInfo
|
||||
}
|
||||
snapshot := func() map[string]recordFile {
|
||||
out := map[string]recordFile{}
|
||||
ents, err := os.ReadDir(chunkRecordDir(path))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, e := range ents {
|
||||
name := chunkRecordDir(path) + "/" + e.Name()
|
||||
b, err := os.ReadFile(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info, err := os.Stat(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = os.SameFile(info, info) // load the file's identity now, not at comparison
|
||||
out[e.Name()] = recordFile{string(b), info}
|
||||
}
|
||||
return out
|
||||
}
|
||||
before := snapshot()
|
||||
next := openForUpgrade(t, path)
|
||||
gen := next.v3.pub.current().SlotGen
|
||||
next.v3.testBeforeSlotWrite = func() error { return errors.New("no publication on a complete record") }
|
||||
if err := upgradeChunkRecord(context.Background(), next, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if next.v3.pub.current().SlotGen != gen {
|
||||
t.Fatal("a descriptor slot was published on a complete record")
|
||||
}
|
||||
after := snapshot()
|
||||
if len(after) != len(before) {
|
||||
t.Fatalf("record files %d -> %d", len(before), len(after))
|
||||
}
|
||||
for name, b := range before {
|
||||
a := after[name]
|
||||
if a.bytes != b.bytes || !os.SameFile(a.info, b.info) || !a.info.ModTime().Equal(b.info.ModTime()) {
|
||||
t.Fatalf("record file %s rewritten on a complete record", name)
|
||||
}
|
||||
}
|
||||
checkUpgradedKinds(t, next)
|
||||
}
|
||||
|
||||
// After the marker the presence file is not evidence: a completed upgrade
|
||||
// whose header is damaged, with a presence file that would say "nothing
|
||||
// absent" (here: one that does not even parse), upgrades again from the
|
||||
// store's bitmap; an absent chunk stays absent.
|
||||
func TestUpgradeChunkRecordAfterTheMarkerIgnoresThePresenceFile(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crashStore(t, s)
|
||||
if err := os.WriteFile(chunkRecordDir(path)+"/"+chunkRecordHeaderName, []byte("damaged"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(chunkPresencePath(path), []byte("not a presence file\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), next, 7); err != nil {
|
||||
t.Fatalf("the upgrade read the presence file after the marker: %v", err)
|
||||
}
|
||||
checkUpgradedKinds(t, next)
|
||||
if c, _, err := next.Coverage(5); err != nil || c != CoverageNone {
|
||||
t.Fatalf("absent chunk 5 coverage %d %v: it would read local bytes, not the remote", c, err)
|
||||
}
|
||||
}
|
||||
|
||||
// A store marked at one epoch is not upgraded at another: refused, and its
|
||||
// bitmap unchanged.
|
||||
func TestUpgradeChunkRecordAtAnotherEpochIsRefused(t *testing.T) {
|
||||
path := legacyVolume(t)
|
||||
s := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), s, 7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crashStore(t, s)
|
||||
next := openForUpgrade(t, path)
|
||||
if err := upgradeChunkRecord(context.Background(), next, 8); err == nil {
|
||||
t.Fatal("an upgrade at another epoch was taken")
|
||||
}
|
||||
if c, _, err := next.Coverage(5); err != nil || c != CoverageNone {
|
||||
t.Fatalf("absent chunk 5 coverage %d %v after a refused upgrade", c, err)
|
||||
}
|
||||
if marked, e := next.ChunkStateMarker(); !marked || e != 7 {
|
||||
t.Fatalf("marker %v/%d after a refused upgrade", marked, e)
|
||||
}
|
||||
}
|
||||
@@ -619,6 +619,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: a matching CRC32C (Castagnoli), every reserved byte zero, an accepted impl, a nonzero slotGen at most 2^64-2, a nonzero nonce, and geometry consistent under checked arithmetic. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `decodeSlotV3`, `descriptorV3.validate`, `checkedAddV3` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3CounterExhaustion` (`core/storage/superblock_v3_test.go`) | — | STUB |
|
||||
| `INV-WAL-V3-DESCRIPTOR-BASE-001` | A valid v3 descriptor slot has CheckpointLSN ≤ mapCoveredCheckpoint ≤ W, and BASE fields that follow the rules of its BASE state. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `descriptorV3.validate` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3InstalledMayHaveCursorBelowTail` (`core/storage/superblock_v3_test.go`) | — | STUB |
|
||||
| `INV-CHUNK-RECORD-PAGES-CURRENT-001` | An unfinished chunk record is used, and its header written, only when every page passes its check and is valid through exactly the store's synced position after recovery (behind: missed writes; ahead: not durable); an unmarked store discards it; the header follows the two-slot fence. | M1 Opened (chunk record load, v1.1 upgrade) | `core/storage/chunk_record.go` `loadChunkRecord`, `completeChunkRecord` | `TestUnfinishedRecordPagesBehindTheStoreAreNotTrusted`, `TestUnfinishedRecordAfterAnOldCheckpointIsDiscarded`, `TestStalePagesAreNeverCompleted`, `TestUnfinishedPagesAheadOfTheStoreAreNotTrusted`, `TestCompleteRecordAheadOfTheStoreIsNotTrusted`, `TestCompleteRecordPagePositions`, `TestRecordHeaderWaitsForTheFence`, `TestRecordHeaderIsNotWrittenAheadOfTheSyncedStore`, `TestDamagedPage` (`core/storage/chunk_record_test.go`) | SlotFence `PagesCurrent`, `FenceHolds`; pages carry chunk-kernel/2 states (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-UPGRADE-001` | The v1.0.x upgrade seeds the bitmap from the presence file only on an unmarked store; marked at this epoch it rebuilds pages from the store's bitmap, at another epoch it refuses; pages precede the fence, the header follows it, the presence file goes last. | M1 Opened (v1.1 upgrade at open) | `core/storage/chunk_record_upgrade.go` `upgradeChunkRecord`, `writeChunkRecordPagesFrom` | `TestUpgradeChunkRecordFromLegacyPresence`, `TestUpgradeChunkRecordCrashBeforeTheFence`, `TestUpgradeChunkRecordCrashAfterTheFence`, `TestUpgradeChunkRecordCrashAfterTheHeader`, `TestUpgradeChunkRecordAfterTheMarkerIgnoresThePresenceFile`, `TestUpgradeChunkRecordAtAnotherEpochIsRefused` (`core/storage/chunk_record_upgrade_test.go`) | UpgradeWide3 (pages, field, header, presence removed); ChunkUpgrade row 118; chunk-kernel/2 `Rebuilt` (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-UPGRADE-PASS-CURSOR-001` | Upgrade pass: rewinds only at open, before Run; a failed rewind latches it until reopen; the persisted cursor is only ever min(earliest unpublished rewind, last written-through position); a restart resumes there; while it runs, a request needing every hash answers in_progress. | M1 Opened (v1.1 upgrade compare pass) | `core/storage/chunk_upgrade_pass.go` `upgradePass.Run`, `advance`, `Rewind`, `Admit` | `TestUpgradePassCursorFollowsThePagesBehindIt`, `TestUpgradePassRestartContinuesAtTheCursor`, `TestUpgradePassRefusesWithProgress`, `TestUpgradePassRewindAtOpenAfterARebuiltPage`, `TestUpgradePassPauseAndHurry`, `TestUpgradePassFailedRewindLatchesUntilReopen`, `TestUpgradePassRewindOnlyBeforeRun`, `TestUpgradePassKeepsItsCountAcrossRuns`, `TestUpgradePassCursorRuleUnderInterleavings` (`core/storage/chunk_upgrade_pass_test.go`) | UpgradePass `BehindCursorKnown`, `NoWorkTwice`; UpgradeWide3 rows 119 to 124, rewinds at restart only (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-RUNTIME-001` | While serving: state only via the kernel, a known hash only with its evidence; a page dirties only when a state or hash changes, is written by its own count or age, an evict's at once, in snapshot order; header G = min(applied, dirty pages' dirty-from). | M3 Serving (chunk record runtime) | `core/storage/chunk_record_runtime.go` `chunkRecordRuntime.Apply`, `Due`, `WriteDue`, `WriteThrough`, `Flush` | `TestRecordRuntimeAppliesTheKernel`, `TestRecordRuntimeEvictWritesThePageFirst`, `TestRecordRuntimeSchedulePerPage`, `TestRecordRuntimeFlushIsLoadedBack`, `TestRecordRuntimeWriteThrough`, `TestRecordRuntimeAnUnchangedStateWritesNothing`, `TestRecordRuntimeHeaderMovesUnderWrites`, `TestRecordRuntimeEvictDuringAFlushLandsLast`, `TestRecordRuntimePageWritesFollowChangesNotSize`, `TestRecordRuntimePageWritersPublishInOrder`, `TestRecordRuntimeHashEvidence`, `TestRecordRuntimeCopiesItsInputs`, `TestRecordRuntimeAPageChangedAtOpenHoldsG` (`core/storage/chunk_record_runtime_test.go`) | chunk-kernel/2; ChunkPages rule 1 (pages before the header) and rule 3 (an evict writes its page first) (the per-chunk state models are not in this repository) | STUB |
|
||||
| `INV-CHUNK-RECORD-SHADOW-001` | While serving, the chunk record follows the engine's events through the kernel; an event bound to a captured version is skipped, never refused, after a write; at each barrier every chunk the engine captures is a record candidate. The record decides nothing and writes no page. | M3 Serving (chunk record shadow) | `core/storage/chunk_record_shadow.go` `newChunkRecordShadow`, `chunkRecordShadow.check`; `core/storage/chunk_layer.go` `noteMutation`, `fillOnce`, `EvictChunk`, `recoveredLocked`, `BeforeCheckpointAdvance`, `shadowCommit`, `shadowCommitCaptured` (also from `resolvePending`, `SettleDetach`); `core/storage/chunk_cut_payload.go` `markEqualNow`; `core/storage/chunk_record_runtime.go` `ApplyIf` | `TestShadowWriteCoverageFollowsTheStoreBitmap`, `TestShadowFillRacedByAWriteEndsUnknown`, `TestShadowCutOfAPartialChunkKeepsItPartial`, `TestShadowAttachKeepsACheckpointedWriteACandidate`, `TestShadowWriteRacingHashAndCommitIsSkippedNotRefused`, `TestShadowEvictEdges`, `TestShadowRecordWritesNoPage`, `TestShadowCheckerIsExactAndCatchesAMissingWrite`, `TestShadowRecoverChangesOnlyTheRecoveredChunks`, `TestShadowBaseInstallCompletingChangesEveryChunk`, `TestShadowDelayedSettlementCommitsTheCapturedChunks`, `TestShadowProductionCheckDoesNotScanTheRecord`, `TestShadowScratchExemptionIsBoundToItsCapturedVersion` (`core/storage/chunk_record_shadow_test.go`); every test of the package runs with the shadow strict, misses and extra record candidates both (`TestMain`, `core/storage/chunk_record_shadow_main_test.go`) | chunk-kernel/2 (the per-chunk state models are not in this repository) | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user