mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
storage, layout: the attach level comes from the assignment; one HEAD write guard
The host keeps the format level of every assignment no older than the newest, the frontend projection carries it, and the provider attaches the chunk layer at it (absent = 0). At level 0 the attach reads HEAD first: a version-1 HEAD runs v1.1 (reported behind), a v1.1 store under a version-0 HEAD is refused, anything else stays v1.0. A v1.1 attach over a remote without the HEAD format is refused. The layout's one HEAD write path refuses a write that raises HEAD from version 0 to version 1 below format level 1, whichever writer tries; writers supply their level in their context. The running format is in the chunk stats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5da9b1dd1
commit
4184e30af4
23 files changed
+477
-48
No files matched your search
@@ -0,0 +1,37 @@
|
||||
package layout
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ErrFormatLevelBelowHeadVersion refuses a HEAD write that would raise HEAD
|
||||
// to version 1 while the cluster format level it runs at is below 1: a v1.0
|
||||
// binary must still read every HEAD until the master's finalize.
|
||||
var ErrFormatLevelBelowHeadVersion = errors.New("layout: format_level_below_head_version: the write would raise HEAD to version 1 below format level 1")
|
||||
|
||||
type formatLevelKey struct{}
|
||||
|
||||
// WithFormatLevel returns ctx carrying the cluster format level the HEAD
|
||||
// writes under it run at. Every writer that may write a version-1 HEAD
|
||||
// supplies it; a ctx without one runs at level 0 (fail closed).
|
||||
func WithFormatLevel(ctx context.Context, level uint8) context.Context {
|
||||
return context.WithValue(ctx, formatLevelKey{}, level)
|
||||
}
|
||||
|
||||
// FormatLevelOf is the format level ctx carries (0 when none).
|
||||
func FormatLevelOf(ctx context.Context) uint8 {
|
||||
level, _ := ctx.Value(formatLevelKey{}).(uint8)
|
||||
return level
|
||||
}
|
||||
|
||||
// checkFormatLevel is the guard every HEAD write passes (runTransition):
|
||||
// below level 1 no write raises HEAD from version 0 to version 1. A HEAD
|
||||
// already at version 1 keeps it (a version never goes down), whatever the
|
||||
// level.
|
||||
func checkFormatLevel(ctx context.Context, h, next Head) error {
|
||||
if next.Version >= HeadVersion1 && h.Version < HeadVersion1 && FormatLevelOf(ctx) < 1 {
|
||||
return ErrFormatLevelBelowHeadVersion
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package layout
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The one guard on the HEAD write path: below format level 1 no writer
|
||||
// raises HEAD from version 0 to version 1, whichever writer tries (a v1.1
|
||||
// commit, the legacy snapshot stamp); at level 1 the same writes land. A
|
||||
// HEAD already at version 1 stays writable at level 0 (a version never goes
|
||||
// down), and a ctx with no level runs at level 0.
|
||||
func TestNoHeadWriteRaisesTheVersionBelowFormatLevelOne(t *testing.T) {
|
||||
me := HolderID{Holder: "srv-a", Epoch: 3, ClaimID: "k-a"}
|
||||
writers := map[string]func(Head) (Head, bool, error){
|
||||
"a v1.1 commit": func(h Head) (Head, bool, error) {
|
||||
next, changed, err := h.Commit(me, "s", RootName{Hash: Sum([]byte("image"))}, h.Position+1, "", SnapshotMeta{}, StateLive)
|
||||
if err == nil && changed {
|
||||
next = next.withManifestBytes("", nil, true)
|
||||
}
|
||||
return next, changed, err
|
||||
},
|
||||
"the legacy snapshot stamp": func(h Head) (Head, bool, error) { return h.StampSnapshotGenerations() },
|
||||
}
|
||||
for name, write := range writers {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
ctx context.Context
|
||||
want error
|
||||
}{
|
||||
{context.Background(), ErrFormatLevelBelowHeadVersion},
|
||||
{WithFormatLevel(context.Background(), 0), ErrFormatLevelBelowHeadVersion},
|
||||
{WithFormatLevel(context.Background(), 1), nil},
|
||||
} {
|
||||
h := idleHead()
|
||||
h.State = StateLive
|
||||
h.Activity = Activity{Kind: ActSnap, Session: "s"}
|
||||
h.Snapshots = map[string]Snapshot{"old": {Root: RootName{}}}
|
||||
st := &memHead{h: &h}
|
||||
next, err := runTransition(tc.ctx, st, CauseCommit, write)
|
||||
if !errors.Is(err, tc.want) {
|
||||
t.Fatalf("at level %d: %v, want %v", FormatLevelOf(tc.ctx), err, tc.want)
|
||||
}
|
||||
if tc.want != nil && (st.updates != 0 || st.h.Version != 0) {
|
||||
t.Fatalf("a refused write reached the store: %d updates, HEAD version %d", st.updates, st.h.Version)
|
||||
}
|
||||
if tc.want == nil && next.Version != HeadVersion1 {
|
||||
t.Fatalf("at level 1: version %d, want 1", next.Version)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
t.Run("a version-1 HEAD at level 0", func(t *testing.T) {
|
||||
h := idleHead()
|
||||
h.State = StateLive
|
||||
h.Version = HeadVersion1
|
||||
st := &memHead{h: &h}
|
||||
if _, err := runTransition(context.Background(), st, CauseSnapshotRetire, func(h Head) (Head, bool, error) {
|
||||
n := h.clone()
|
||||
n.Position++
|
||||
return n, true, nil
|
||||
}); err != nil {
|
||||
t.Fatalf("a write keeping HEAD at version 1 at level 0: %v, want it to land", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -681,6 +681,9 @@ func runTransition(ctx context.Context, st HeadStore, cause HeadWriteCause, t fu
|
||||
if err != nil || !changed {
|
||||
return next, err
|
||||
}
|
||||
if err := checkFormatLevel(ctx, h, next); err != nil {
|
||||
return Head{}, err
|
||||
}
|
||||
if err := next.check(); err != nil {
|
||||
return Head{}, err
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func kernelCell(t *testing.T, state, entry string) string {
|
||||
o.put(rel, raw, "s1")
|
||||
cursor := ListCursor{Ref: ref, Kind: p.Kind, Producer: p.Producer, Generation: p.Generation}
|
||||
if entry == "PublishList" {
|
||||
_, err = RunPublishList(ctx, cs, me, "s1", h.Gen, cursor)
|
||||
_, err = RunPublishList(WithFormatLevel(ctx, 1), cs, me, "s1", h.Gen, cursor) // a v1.1 writer runs at level 1
|
||||
} else {
|
||||
if nv.memHead.h != nil {
|
||||
nv.memHead.h.Version = HeadVersion1
|
||||
|
||||
@@ -187,7 +187,7 @@ func TestLayoutStoreListPublishConsumeAndRetire(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c := layout.ListCursor{Ref: r, Kind: p.Kind, Producer: p.Producer, Generation: p.Generation}
|
||||
if _, err := layout.RunPublishList(ctx, s, me, "s1", 1, c); err != nil {
|
||||
if _, err := layout.RunPublishList(layout.WithFormatLevel(ctx, 1), s, me, "s1", 1, c); err != nil { // a v1.1 writer runs at level 1
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := layout.RunAbort(ctx, s, me, "s1", layout.CauseSessionRollback); err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package chunkstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
@@ -153,7 +154,7 @@ func TestACommitByChangeKeepsAnUnchangedTouchedSegmentInTheSize(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The remote's HEAD format follows the attaching layer (SetHeadFormatV11),
|
||||
// The remote's HEAD format follows the attaching layer (SetHeadFormat),
|
||||
// not the build: a remote left at v1.0 commits version 0, and once its layer
|
||||
// sets v1.1 the next commit writes version 1 and HeadV11 reports it.
|
||||
func TestLayoutRemoteHeadFormatFollowsItsLayer(t *testing.T) {
|
||||
@@ -165,7 +166,7 @@ func TestLayoutRemoteHeadFormatFollowsItsLayer(t *testing.T) {
|
||||
if h.Version != 0 || r.HeadV11() {
|
||||
t.Fatalf("a remote never set to v1.1 committed version %d (HeadV11 %v)", h.Version, r.HeadV11())
|
||||
}
|
||||
r.SetHeadFormatV11(true)
|
||||
r.SetHeadFormat(true, 1)
|
||||
ref := putChunk(t, ctx, r, layout.ShardSize+9, "second")
|
||||
changes := map[uint64]*storage.ChunkRef{layout.ShardSize + 9: &ref}
|
||||
exp := storage.ChunkHeadVersion{Gen: h1.Gen, Epoch: 1}
|
||||
@@ -187,3 +188,23 @@ func TestLayoutRemoteHeadFormatFollowsItsLayer(t *testing.T) {
|
||||
t.Fatalf("HeadV11 after reading a version-1 HEAD: %v %v", r.HeadV11(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// A remote whose layer set the v1.1 format at format level 0 (a layer that
|
||||
// wrongly chose v1.1 below the level) cannot raise HEAD: the layout's one
|
||||
// HEAD write guard refuses the commit, typed, and HEAD stays version 0.
|
||||
func TestALevelZeroCommitCannotRaiseHeadToVersionOne(t *testing.T) {
|
||||
ctx, _, r, h1 := threeShardVolume(t)
|
||||
r.SetHeadFormat(true, 0)
|
||||
ref := putChunk(t, ctx, r, layout.ShardSize+9, "second")
|
||||
changes := map[uint64]*storage.ChunkRef{layout.ShardSize + 9: &ref}
|
||||
exp := storage.ChunkHeadVersion{Gen: h1.Gen, Epoch: 1}
|
||||
next := storage.ChunkHead{Epoch: 1, RemoteLSN: 2}
|
||||
_, err := r.CASHeadDelta(ctx, exp, next, changes)
|
||||
if !errors.Is(err, layout.ErrFormatLevelBelowHeadVersion) {
|
||||
t.Fatalf("a v1.1 commit at level 0 over a version-0 HEAD: %v, want format_level_below_head_version", err)
|
||||
}
|
||||
h, _, err := r.st.ReadHead(ctx)
|
||||
if err != nil || h.Version != 0 {
|
||||
t.Fatalf("HEAD after the refused commit: version %d %v, want 0", h.Version, err)
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,11 @@ type LayoutRemote struct {
|
||||
vol VolumeRef
|
||||
me layout.HolderID
|
||||
|
||||
// headV11: commits write a v1.1 HEAD (SetHeadFormatV11, at attach);
|
||||
// headV11: commits write a v1.1 HEAD (SetHeadFormat, at attach), at
|
||||
// the format level headLevel (the HEAD write guard's input);
|
||||
// readV11: the HEAD last read is version 1 (HeadV11).
|
||||
headV11, readV11 atomic.Bool
|
||||
headLevel atomic.Uint32
|
||||
|
||||
mu sync.Mutex
|
||||
session string
|
||||
@@ -701,7 +703,7 @@ func cloneChunkHead(h storage.ChunkHead) storage.ChunkHead {
|
||||
func (l *LayoutRemote) commitStepLocked(ctx context.Context, req layout.CommitRequest) (layout.Head, error) {
|
||||
step, cancel := headStep(ctx)
|
||||
defer cancel()
|
||||
return layout.RunCommit(step, l.st, l.st, l.vol.Name, l.me, req, layout.CauseCommit)
|
||||
return layout.RunCommit(l.atFormatLevel(step), l.st, l.st, l.vol.Name, l.me, req, layout.CauseCommit)
|
||||
}
|
||||
|
||||
// isCheckedLocked reports whether expected and next are exactly the checked
|
||||
@@ -951,10 +953,25 @@ func (l *LayoutRemote) writeRootLocked(ctx context.Context, next map[uint64]layo
|
||||
return size, layoutRemoteErr(err)
|
||||
}
|
||||
|
||||
// SetHeadFormatV11 is storage.ChunkHeadFormatter: the attaching layer's
|
||||
// format decides whether this remote's commits write a v1.1 HEAD (version 1,
|
||||
// the manifest sizes). Set once at attach, before any commit.
|
||||
func (l *LayoutRemote) SetHeadFormatV11(v11 bool) { l.headV11.Store(v11) }
|
||||
// SetHeadFormat is storage.ChunkHeadFormatter: the attaching layer's format
|
||||
// decides whether this remote's commits write a v1.1 HEAD (version 1, the
|
||||
// manifest sizes), and its format level is what each commit's HEAD write
|
||||
// runs at (layout.WithFormatLevel). Set once at attach, before any commit.
|
||||
func (l *LayoutRemote) SetHeadFormat(v11 bool, level uint8) {
|
||||
l.headV11.Store(v11)
|
||||
l.headLevel.Store(uint32(level))
|
||||
}
|
||||
|
||||
// atFormatLevel is ctx carrying this remote's format level for a HEAD write.
|
||||
// This package's tests that force the v1.1 sizes on (manifestSizesTestOverride)
|
||||
// write as a level-1 attach would.
|
||||
func (l *LayoutRemote) atFormatLevel(ctx context.Context) context.Context {
|
||||
level := uint8(l.headLevel.Load())
|
||||
if f := manifestSizesTestOverride; f != nil && f() {
|
||||
level = 1
|
||||
}
|
||||
return layout.WithFormatLevel(ctx, level)
|
||||
}
|
||||
|
||||
// HeadV11 is storage.ChunkHeadFormatter: whether the HEAD this remote last
|
||||
// read is version 1 (a v1.1 HEAD).
|
||||
@@ -1141,7 +1158,7 @@ func (l *LayoutRemote) CommitPendingSnapshot(ctx context.Context) error {
|
||||
if l.manifestSizesV11() {
|
||||
req.ManifestBytes = &size
|
||||
}
|
||||
got, err := layout.RunCommit(ctx, l.st, l.st, l.vol.Name, l.me, req, layout.CauseSnapshotUnchanged)
|
||||
got, err := layout.RunCommit(l.atFormatLevel(ctx), l.st, l.st, l.vol.Name, l.me, req, layout.CauseSnapshotUnchanged)
|
||||
if err != nil {
|
||||
if snapshotRefusal(err) {
|
||||
l.pending = nil
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package durable
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
)
|
||||
|
||||
type recordingFormatter struct {
|
||||
storage.ChunkRemote
|
||||
set []bool
|
||||
levels []uint8
|
||||
v11 bool
|
||||
}
|
||||
|
||||
func (r *recordingFormatter) SetHeadFormat(v11 bool, level uint8) {
|
||||
r.set, r.levels = append(r.set, v11), append(r.levels, level)
|
||||
}
|
||||
func (r *recordingFormatter) HeadV11() bool { return r.v11 }
|
||||
|
||||
// The provider's wrapped remote forwards the layer's HEAD format to the
|
||||
// remote it wraps and the wrapped remote's HEAD version back, so the
|
||||
// wrapper never hides the format the attach selected; over a remote that
|
||||
// cannot take it, the wrapper reports a v1.0 HEAD (the attach then refuses
|
||||
// a v1.1 store rather than guess).
|
||||
func TestTheWrappedRemoteForwardsTheHeadFormatBothWays(t *testing.T) {
|
||||
inner := &recordingFormatter{}
|
||||
wrapped := storage.ChunkRemote(&layoutBoundRemote{closeBoundRemote: &closeBoundRemote{ChunkRemote: inner, done: context.Background()}})
|
||||
f, ok := wrapped.(storage.ChunkHeadFormatter)
|
||||
if !ok {
|
||||
t.Fatal("the wrapped remote is no ChunkHeadFormatter")
|
||||
}
|
||||
f.SetHeadFormat(true, 1)
|
||||
if len(inner.set) != 1 || !inner.set[0] || inner.levels[0] != 1 {
|
||||
t.Fatalf("the selected HEAD format did not reach the wrapped remote: %v at levels %v", inner.set, inner.levels)
|
||||
}
|
||||
if f.HeadV11() {
|
||||
t.Fatal("HeadV11 true before the wrapped remote read a version-1 HEAD")
|
||||
}
|
||||
inner.v11 = true
|
||||
if !f.HeadV11() {
|
||||
t.Fatal("the wrapped remote's version-1 HEAD did not come back through the wrapper")
|
||||
}
|
||||
plain := storage.ChunkRemote(&layoutBoundRemote{closeBoundRemote: &closeBoundRemote{ChunkRemote: struct{ storage.ChunkRemote }{}, done: context.Background()}})
|
||||
pf := plain.(storage.ChunkHeadFormatter)
|
||||
pf.SetHeadFormat(true, 1) // nothing to forward to: a no-op
|
||||
if pf.HeadV11() {
|
||||
t.Fatal("a wrapper over a remote without the HEAD format reported a version-1 HEAD")
|
||||
}
|
||||
}
|
||||
|
||||
// The attach level comes from the assignment's: absent or 0 keeps v1.0, 1
|
||||
// may upgrade, and a level above what this binary knows reads as 1.
|
||||
func TestAttachFormatLevelFromTheAssignment(t *testing.T) {
|
||||
for assigned, want := range map[uint32]uint8{0: 0, 1: 1, 2: 1} {
|
||||
if got := attachFormatLevel(assigned); got != want {
|
||||
t.Fatalf("assigned %d: attach level %d, want %d", assigned, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +544,7 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h
|
||||
Epoch: lin.epoch,
|
||||
Holder: holder,
|
||||
FreshFromHead: h.fresh,
|
||||
FormatLevel: 0, // the assignment's level once it carries one; absent = 0
|
||||
FormatLevel: attachFormatLevel(proj.FormatLevel),
|
||||
CleanStop: cleanStop,
|
||||
CreatedThisStart: h.fresh && h.createdThisStart,
|
||||
ReadMissTimeout: p.cfg.ChunkReadMissTimeout,
|
||||
@@ -623,12 +623,12 @@ type layoutRemoteCapabilities interface {
|
||||
// closeBoundRemote ends every remote call when the provider closes, so a
|
||||
// shutdown never waits on the remote for an attach or a cut. While an
|
||||
// attach runs, its calls also end with the attach caller's context.
|
||||
// SetHeadFormatV11 forwards the attaching layer's HEAD format to the
|
||||
// SetHeadFormat forwards the attaching layer's HEAD format to the
|
||||
// remote it wraps (storage.ChunkHeadFormatter), so the wrapper never hides
|
||||
// it: a remote that does not take it writes as it always did.
|
||||
func (r *closeBoundRemote) SetHeadFormatV11(v11 bool) {
|
||||
func (r *closeBoundRemote) SetHeadFormat(v11 bool, level uint8) {
|
||||
if f, ok := r.ChunkRemote.(storage.ChunkHeadFormatter); ok {
|
||||
f.SetHeadFormatV11(v11)
|
||||
f.SetHeadFormat(v11, level)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,17 @@ func initializeLayoutRoot(ws *storage.WALStore) error {
|
||||
return ws.SetLayoutIdentity(hex.EncodeToString(id[:]), true)
|
||||
}
|
||||
|
||||
// attachFormatLevel is the chunk layer's format level from the assignment's:
|
||||
// 0 (also when absent) keeps a v1.0 store on v1.0; 1 lets the attach
|
||||
// upgrade it. A higher level than this binary knows is read as 1, the
|
||||
// highest format it writes.
|
||||
func attachFormatLevel(assigned uint32) uint8 {
|
||||
if assigned >= 1 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// grantedLayoutLine carries the actual assignment accepted by the volume
|
||||
// host. The master issues a higher epoch only after its clean proof or forced
|
||||
// lease barrier; the grant is the proof, not a local clock or a HEAD read.
|
||||
|
||||
@@ -36,6 +36,10 @@ type Projection struct {
|
||||
Epoch uint64 // the authority epoch of the current assignment
|
||||
EndpointVersion uint64 // the assignment's endpoint version within the epoch
|
||||
Healthy bool // the replica may serve I/O at this epoch
|
||||
// FormatLevel is the cluster format level the master's assignment
|
||||
// carries (0 when absent: an older master, or none yet): an attach may
|
||||
// raise a store to the v1.1 format only at level 1.
|
||||
FormatLevel uint32
|
||||
}
|
||||
|
||||
// ProjectionView is the read-only seam between adapter/engine
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package volume
|
||||
|
||||
import "testing"
|
||||
|
||||
// The master's format level (AssignmentFact.format_level) reaches the
|
||||
// frontend projection from the self assignment the host applies; a fact
|
||||
// without it (an older master) reads 0, and a later fact replaces it.
|
||||
func TestTheSelfAssignmentsFormatLevelReachesTheProjection(t *testing.T) {
|
||||
h, _, _ := newStubbedHost(t, "vol1", "rB", &orderingRecorder{})
|
||||
view := &AdapterProjectionView{probe: h} // the bridge reads the level from its host
|
||||
if got := view.formatLevel(); got != 0 {
|
||||
t.Fatalf("before any assignment: format level %d, want 0", got)
|
||||
}
|
||||
fact := selfFact(2)
|
||||
fact.FormatLevel = 1
|
||||
h.applyFact(fact)
|
||||
if got := view.formatLevel(); got != 1 || h.FormatLevel() != 1 {
|
||||
t.Fatalf("after a level-1 assignment: format level %d (host %d), want 1", got, h.FormatLevel())
|
||||
}
|
||||
h.applyFact(selfFact(3)) // an older master's fact carries no level
|
||||
if got := view.formatLevel(); got != 0 {
|
||||
t.Fatalf("after an assignment without a level: format level %d, want 0 (absent fails closed)", got)
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,9 @@ type Host struct {
|
||||
// replicated line under another ack profile than this volume's own
|
||||
// (AckProfileRefusal); while set the frontend is not Healthy.
|
||||
ackProfileRefusal atomic.Value
|
||||
// formatLevel is the format level of the latest self assignment
|
||||
// (AssignmentFact.format_level; absent = 0).
|
||||
formatLevel atomic.Uint32
|
||||
// roleRetry: the last replica role call failed with an error a retry
|
||||
// may outlast (a floor that could not be persisted); runRoleRetry
|
||||
// re-applies the current role until it succeeds or is refused for good.
|
||||
@@ -1054,6 +1057,12 @@ func (h *Host) applyFact(fact *control.AssignmentFact) {
|
||||
if fact.GetEpoch() > h.factEpochSeen {
|
||||
h.factEpochSeen = fact.GetEpoch()
|
||||
}
|
||||
// The cluster's format level, from every fact no older than the newest
|
||||
// seen, before anything below can attach a store (a late replay of an
|
||||
// older fact never changes it).
|
||||
if fact.GetEpoch() >= h.factEpochSeen {
|
||||
h.formatLevel.Store(fact.GetFormatLevel())
|
||||
}
|
||||
h.selfFenceMu.Unlock()
|
||||
// INV-AUTH-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host.
|
||||
if h.refusePrimaryAssignment(fact) {
|
||||
|
||||
@@ -116,6 +116,7 @@ func (v *AdapterProjectionView) projectionWithSupersede() (frontend.Projection,
|
||||
Epoch: p.Epoch,
|
||||
EndpointVersion: p.EndpointVersion,
|
||||
Healthy: healthy,
|
||||
FormatLevel: v.formatLevel(),
|
||||
}
|
||||
if v.workspaceRequired {
|
||||
guard := v.workspaceGuard.Load()
|
||||
@@ -170,6 +171,19 @@ func (v *AdapterProjectionView) replicaStoresAwaited() string {
|
||||
// ackProfileRefusal: a primary of a replicated line assigned under another
|
||||
// ack profile than its own serves nothing (Host.AckProfileRefusal); "" when
|
||||
// it may serve.
|
||||
// formatLevel is the latest self assignment's format level, from the host
|
||||
// (0 without one).
|
||||
func (v *AdapterProjectionView) formatLevel() uint32 {
|
||||
if v == nil || v.probe == nil {
|
||||
return 0
|
||||
}
|
||||
probe, ok := v.probe.(interface{ FormatLevel() uint32 })
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return probe.FormatLevel()
|
||||
}
|
||||
|
||||
func (v *AdapterProjectionView) ackProfileRefusal() string {
|
||||
if v == nil || v.probe == nil {
|
||||
return ""
|
||||
|
||||
@@ -109,6 +109,10 @@ func (h *Host) AckProfileRefusal() string {
|
||||
return reason
|
||||
}
|
||||
|
||||
// FormatLevel is the format level of the latest self assignment (0 when
|
||||
// none, or when its master sends none).
|
||||
func (h *Host) FormatLevel() uint32 { return h.formatLevel.Load() }
|
||||
|
||||
func canonicalAckProfile(p string) string {
|
||||
return strings.ToLower(strings.ReplaceAll(p, "-", "_"))
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (f *fakeChunkRemote) releaseDeferredCAS() int {
|
||||
// guarded by mu.
|
||||
type fakeChunkRemote struct {
|
||||
mu sync.Mutex
|
||||
// writeV11: the attach set the v1.1 HEAD format (SetHeadFormatV11); headV11:
|
||||
// writeV11: the attach set the v1.1 HEAD format (SetHeadFormat); headV11:
|
||||
// a CAS made under it installed a version-1 HEAD (one way, as a real HEAD).
|
||||
writeV11, headV11 bool
|
||||
objs map[string][]byte
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func (f *fakeChunkRemote) SetHeadFormatV11(v11 bool) {
|
||||
func (f *fakeChunkRemote) SetHeadFormat(v11 bool, _ uint8) {
|
||||
f.mu.Lock()
|
||||
f.writeV11 = v11
|
||||
f.mu.Unlock()
|
||||
@@ -73,6 +73,16 @@ func TestAttachFormatFollowsTheAssignedLevel(t *testing.T) {
|
||||
if l2.v11 || storeMarked(t, r) || f.HeadV11() {
|
||||
t.Fatalf("after the restart at level 0: v1.1 %v, marked %v, HEAD v1 %v; want v1.0 throughout", l2.v11, storeMarked(t, r), f.HeadV11())
|
||||
}
|
||||
casBefore := f.stats().cas
|
||||
if _, err := r.Write(1, makeBlock(ctBlockSize, 0xA2)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := l2.Cut(ctTimeout(t)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if f.stats().cas == casBefore || f.HeadV11() || l2.Stats().FormatV11 {
|
||||
t.Fatalf("the cut after the restart at level 0: published %v, HEAD v1 %v, stats v1.1 %v; want a version-0 publication", f.stats().cas != casBefore, f.HeadV11(), l2.Stats().FormatV11)
|
||||
}
|
||||
})
|
||||
t.Run("level 1", func(t *testing.T) {
|
||||
s, _, f := uncleanUpgradeStore(t)
|
||||
@@ -139,11 +149,12 @@ func TestAttachAtLevelZeroOfAnUpgradedStore(t *testing.T) {
|
||||
crashStore(t, s)
|
||||
r := reopenRecovered(t, path)
|
||||
r.HoldExtentDrainUntilChunkLayer()
|
||||
before := f.stats()
|
||||
if _, err := levelAttach(t, r, f, 0); !errors.Is(err, ErrFormatLevelBehindStore) {
|
||||
t.Fatalf("level 0 over a v1.1 store with a version-0 HEAD: %v, want format_level_behind_store", err)
|
||||
}
|
||||
if f.HeadV11() {
|
||||
t.Fatal("the refused attach wrote a version-1 HEAD")
|
||||
if after := f.stats(); f.HeadV11() || after.cas != before.cas || after.puts != before.puts {
|
||||
t.Fatalf("the refused attach wrote: HEAD v1 %v, CAS %d->%d, puts %d->%d; want nothing", f.HeadV11(), before.cas, after.cas, before.puts, after.puts)
|
||||
}
|
||||
l3, err := levelAttach(t, r, f, 1)
|
||||
if err != nil || !l3.v11 || l3.Stats().FormatLevelBehindVolume {
|
||||
@@ -151,3 +162,96 @@ func TestAttachAtLevelZeroOfAnUpgradedStore(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// At level 0 an unmarked store under a HEAD already at version 1 (another
|
||||
// holder upgraded the volume) is served as v1.1: the volume's format is
|
||||
// already 1, so upgrading the local store raises nothing, and a HEAD never
|
||||
// goes back to version 0. It is reported as format_level_behind_volume.
|
||||
func TestAttachAtLevelZeroOfAV11HeadOverAnUnmarkedStore(t *testing.T) {
|
||||
v10Only(t)
|
||||
withoutUpgradePass(t)
|
||||
s, _, f := uncleanUpgradeStore(t)
|
||||
f.mu.Lock()
|
||||
f.headV11 = true // the volume's HEAD is already version 1
|
||||
f.mu.Unlock()
|
||||
l, err := levelAttach(t, s, f, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("level 0 over a version-1 HEAD: %v, want served", err)
|
||||
}
|
||||
if !l.v11 || !storeMarked(t, s) || !l.Stats().FormatLevelBehindVolume || !l.Stats().FormatV11 {
|
||||
t.Fatalf("level 0 over a version-1 HEAD: v1.1 %v, marked %v, behind %v; want served as v1.1, reported", l.v11, storeMarked(t, s), l.Stats().FormatLevelBehindVolume)
|
||||
}
|
||||
if _, err := s.Write(0, makeBlock(ctBlockSize, 0xC1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := l.Cut(ctTimeout(t)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.mu.Lock()
|
||||
wrote := f.writeV11
|
||||
f.mu.Unlock()
|
||||
if !wrote {
|
||||
t.Fatal("the cut over a version-1 HEAD was set to write version 0")
|
||||
}
|
||||
}
|
||||
|
||||
// formatlessRemote hides the fake's HEAD-format methods (an interface
|
||||
// field promotes only chunkRemote's).
|
||||
type formatlessRemote struct{ chunkRemote }
|
||||
|
||||
// A v1.1 attach over a remote that cannot take the HEAD format is refused
|
||||
// before it writes anything: it would publish v1.0 HEADs over a v1.1 store.
|
||||
// At level 0 over a v1.0 store such a remote attaches as before.
|
||||
func TestAV11AttachRefusesARemoteWithoutTheHeadFormat(t *testing.T) {
|
||||
v10Only(t)
|
||||
withoutUpgradePass(t)
|
||||
s, _, f := uncleanUpgradeStore(t)
|
||||
cfg := ctConfig(2)
|
||||
cfg.Bitmap = nil
|
||||
cfg.FormatLevel = 1
|
||||
before := f.stats()
|
||||
if _, err := attachChunkLayer(s, formatlessRemote{f}, cfg); !errors.Is(err, ErrHeadFormatUnsupported) {
|
||||
t.Fatalf("level 1 over a remote without the HEAD format: %v, want head_format_unsupported", err)
|
||||
}
|
||||
if after := f.stats(); storeMarked(t, s) || after.cas != before.cas || after.puts != before.puts {
|
||||
t.Fatalf("the refused attach wrote: marked %v, CAS %d->%d, puts %d->%d", storeMarked(t, s), before.cas, after.cas, before.puts, after.puts)
|
||||
}
|
||||
cfg.FormatLevel = 0
|
||||
l, err := attachChunkLayer(s, formatlessRemote{f}, cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("level 0 over a v1.0 store and a remote without the HEAD format: %v", err)
|
||||
}
|
||||
_ = l.Close()
|
||||
}
|
||||
|
||||
// Level 1 marks the store at attach; HEAD becomes version 1 at the first v1.1
|
||||
// cut. A crash between the two (a marked store under a version-0 HEAD, still
|
||||
// at level 1) reattaches at level 1 as v1.1, and the next cut writes the
|
||||
// version-1 HEAD.
|
||||
func TestALevelOneCrashBeforeTheFirstCutReattachesAsV11(t *testing.T) {
|
||||
v10Only(t)
|
||||
withoutUpgradePass(t)
|
||||
s, path, f := uncleanUpgradeStore(t)
|
||||
if _, err := levelAttach(t, s, f, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !storeMarked(t, s) || f.HeadV11() {
|
||||
t.Fatalf("setup: marked %v, HEAD v1 %v; want a marked store under a version-0 HEAD", storeMarked(t, s), f.HeadV11())
|
||||
}
|
||||
crashStore(t, s) // killed between the attach and its first cut
|
||||
r := reopenRecovered(t, path)
|
||||
r.HoldExtentDrainUntilChunkLayer()
|
||||
l, err := levelAttach(t, r, f, 1)
|
||||
if err != nil || !l.v11 || l.Stats().FormatLevelBehindVolume {
|
||||
t.Fatalf("the reattach at level 1: %v (v1.1 %v); want v1.1, not behind", err, l != nil && l.v11)
|
||||
}
|
||||
if _, err := r.Write(0, makeBlock(ctBlockSize, 0xD1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := l.Cut(ctTimeout(t)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !f.HeadV11() {
|
||||
t.Fatal("the first cut after the reattach wrote a version-0 HEAD")
|
||||
}
|
||||
}
|
||||
@@ -342,12 +342,9 @@ func attachChunkLayerImpl(s *WALStore, remote chunkRemote, cfg chunkLayerConfig)
|
||||
}
|
||||
l.chunkMut = make([]atomic.Uint64, l.numChunks)
|
||||
storeMarked, _ := s.ChunkStateMarker()
|
||||
var checkFormatHead bool
|
||||
l.v11, checkFormatHead = attachFormat(cfg.FormatLevel, storeMarked)
|
||||
l.v11 = attachLevelV11(cfg.FormatLevel)
|
||||
levelZero := !l.v11 // HEAD decides the format (levelZeroFormat)
|
||||
formatter, _ := remote.(ChunkHeadFormatter)
|
||||
if formatter != nil {
|
||||
formatter.SetHeadFormatV11(l.v11)
|
||||
}
|
||||
l.attachProgress = attachProgress{report: cfg.AttachProgress}
|
||||
defer l.attachProgress.flush() // work completed by a failed attempt still counts
|
||||
var nb8 [8]byte
|
||||
@@ -362,13 +359,26 @@ func attachChunkLayerImpl(s *WALStore, remote chunkRemote, cfg chunkLayerConfig)
|
||||
l.cancel()
|
||||
return nil, fmt.Errorf("storage: chunk layer attach: read HEAD: %w", err)
|
||||
}
|
||||
if checkFormatHead {
|
||||
if formatter == nil || !formatter.HeadV11() {
|
||||
if levelZero {
|
||||
v11, behind, ferr := levelZeroFormat(formatter != nil && formatter.HeadV11(), storeMarked)
|
||||
if ferr != nil {
|
||||
l.cancel()
|
||||
return nil, ErrFormatLevelBehindStore
|
||||
return nil, ferr
|
||||
}
|
||||
l.formatBehind = true
|
||||
log.Printf("level=WARN storage: chunk layer attach: format_level_behind_volume: assigned format level 0, the store and HEAD are on v1.1; served as v1.1")
|
||||
if v11 {
|
||||
// HEAD was read whole (the v1.0 read): it moves to the ref table.
|
||||
l.v11, l.formatBehind = true, behind
|
||||
l.setHeadLocked(head)
|
||||
head = l.head
|
||||
log.Printf("level=WARN storage: chunk layer attach: format_level_behind_volume: assigned format level 0, HEAD is on v1.1; served as v1.1")
|
||||
}
|
||||
}
|
||||
if l.v11 && formatter == nil {
|
||||
l.cancel()
|
||||
return nil, ErrHeadFormatUnsupported
|
||||
}
|
||||
if formatter != nil {
|
||||
formatter.SetHeadFormat(l.v11, attachLevel(cfg.FormatLevel)) // once the format is known: a refused attach set nothing
|
||||
}
|
||||
l.remoteLSN = head.RemoteLSN
|
||||
// A HEAD that already belongs to a newer epoch or a competing holder is
|
||||
@@ -2438,6 +2448,7 @@ func (l *chunkLayerImpl) Stats() chunkLayerStats {
|
||||
}
|
||||
out.UpgradePass = l.upgradePassStatusLocked()
|
||||
out.FormatLevelBehindVolume = l.formatBehind
|
||||
out.FormatV11 = l.v11
|
||||
out.Hydration.WorkerLimit = l.cfg.HydrationWorkers
|
||||
out.Hydration.QueueDepth = l.cfg.HydrationQueueDepth
|
||||
for _, f := range l.hydration {
|
||||
|
||||
@@ -23,6 +23,23 @@ type MemChunkRemote struct {
|
||||
// Begin that opened one, aborts every Abort that ended one.
|
||||
session string
|
||||
sessions, aborts int
|
||||
// writeV11: its layer set the v1.1 HEAD format; headV11: a CAS made
|
||||
// under it installed a version-1 HEAD (one way, as a real HEAD).
|
||||
writeV11, headV11 bool
|
||||
}
|
||||
|
||||
// SetHeadFormat is ChunkHeadFormatter: the HEAD format its CASes write.
|
||||
func (m *MemChunkRemote) SetHeadFormat(v11 bool, _ uint8) {
|
||||
m.mu.Lock()
|
||||
m.writeV11 = v11
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
// HeadV11 is ChunkHeadFormatter: whether its HEAD is version 1.
|
||||
func (m *MemChunkRemote) HeadV11() bool {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
return m.headV11
|
||||
}
|
||||
|
||||
func NewMemChunkRemote() *MemChunkRemote {
|
||||
@@ -123,6 +140,9 @@ func (m *MemChunkRemote) CASHead(ctx context.Context, expected chunkHeadVersion,
|
||||
installed := copyHead(next)
|
||||
installed.Gen = m.head.Gen + 1
|
||||
m.head = installed
|
||||
if m.writeV11 {
|
||||
m.headV11 = true
|
||||
}
|
||||
m.session = "" // the commit ends the cut's session
|
||||
return installed.Gen, nil
|
||||
}
|
||||
|
||||
@@ -535,6 +535,9 @@ type chunkLayerStats struct {
|
||||
// FormatLevelBehindVolume: attached at format level 0 to a store and HEAD
|
||||
// already on v1.1 (format_level_behind_volume): served as v1.1.
|
||||
FormatLevelBehindVolume bool
|
||||
// FormatV11: the layer runs the v1.1 store format (decided at attach
|
||||
// from its format level and the store): what a gate asserts it measured.
|
||||
FormatV11 bool
|
||||
// BarrierOverBound counts cuts whose barrier copied more than the
|
||||
// bound after the staging rounds.
|
||||
BarrierOverBound uint64
|
||||
|
||||
@@ -7,26 +7,41 @@ import "errors"
|
||||
// mode). Production attaches run at their config's FormatLevel.
|
||||
var chunkFormatLevelTestFloor uint8
|
||||
|
||||
// attachFormat is an attach's format decision from its level and the store's
|
||||
// marker. The level only decides whether the attach may RAISE a volume's
|
||||
// format (FormatGate's Upgrade1, only at level 1); a format never goes down.
|
||||
// At level 0 a store already marked v1.1 runs v1.1, but only over a HEAD
|
||||
// already at version 1 (checkHead: the attach confirms it after reading
|
||||
// HEAD); never max(level, marker).
|
||||
func attachFormat(level uint8, marked bool) (v11, checkHead bool) {
|
||||
if chunkFormatLevelTestFloor > level {
|
||||
level = chunkFormatLevelTestFloor
|
||||
}
|
||||
// attachLevelV11 says whether an attach at level runs the v1.1 format from
|
||||
// the start (level 1: it may raise the volume's format, FormatGate's
|
||||
// Upgrade1). At level 0 the attach decides after reading HEAD
|
||||
// (levelZeroFormat): the level only decides whether an attach may RAISE a
|
||||
// volume's format, and a format never goes down.
|
||||
func attachLevelV11(level uint8) bool { return attachLevel(level) >= 1 }
|
||||
|
||||
// attachLevel is the format level an attach runs at: its config's, raised
|
||||
// by this package's tests only (chunkFormatLevelTestFloor).
|
||||
func attachLevel(level uint8) uint8 {
|
||||
return max(level, chunkFormatLevelTestFloor)
|
||||
}
|
||||
|
||||
// levelZeroFormat is a level-0 attach's format once it read HEAD: over a
|
||||
// version-1 HEAD the volume is already v1.1, so it runs v1.1 (behind: the
|
||||
// assigned level lags the volume; the store is upgraded if it is not yet,
|
||||
// which raises no volume's format); over a version-0 HEAD a store already
|
||||
// marked v1.1 is refused (serving it would write a version-1 HEAD at level
|
||||
// 0, or downgrade the store); otherwise v1.0. Never max(level, marker).
|
||||
func levelZeroFormat(headV11, marked bool) (v11, behind bool, err error) {
|
||||
switch {
|
||||
case level >= 1:
|
||||
return true, false
|
||||
case !marked:
|
||||
return false, false
|
||||
case headV11:
|
||||
return true, true, nil
|
||||
case marked:
|
||||
return false, false, ErrFormatLevelBehindStore
|
||||
default:
|
||||
return true, true
|
||||
return false, false, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ErrHeadFormatUnsupported refuses a v1.1 attach whose remote cannot take
|
||||
// the HEAD format (it is no ChunkHeadFormatter): it would write v1.0 HEADs
|
||||
// over a v1.1 store.
|
||||
var ErrHeadFormatUnsupported = errors.New("storage: head_format_unsupported: the remote cannot write the v1.1 HEAD format the attach runs")
|
||||
|
||||
// ErrFormatLevelBehindStore refuses an attach at level 0 of a store already
|
||||
// upgraded to v1.1 whose HEAD is still version 0: serving it would write a
|
||||
// version-1 HEAD at level 0, or downgrade the store, and both are refused.
|
||||
@@ -34,10 +49,11 @@ func attachFormat(level uint8, marked bool) (v11, checkHead bool) {
|
||||
var ErrFormatLevelBehindStore = errors.New("storage: format_level_behind_store: the store is on the v1.1 format, its HEAD is not, and the assigned format level is 0")
|
||||
|
||||
// ChunkHeadFormatter is a remote whose HEAD format follows the attach: the
|
||||
// layer sets the write format once at attach, before any HEAD write (a layer
|
||||
// on the v1.0 format writes a v1.0 HEAD, one on v1.1 a v1.1 HEAD), and asks
|
||||
// layer sets the write format and its format level once at attach, before
|
||||
// any HEAD write (a layer on the v1.0 format writes a v1.0 HEAD, one on v1.1
|
||||
// a v1.1 HEAD; the level is what the HEAD write guard checks), and asks
|
||||
// whether the HEAD it read at attach is already version 1.
|
||||
type ChunkHeadFormatter interface {
|
||||
SetHeadFormatV11(v11 bool)
|
||||
SetHeadFormat(v11 bool, level uint8)
|
||||
HeadV11() bool
|
||||
}
|
||||
@@ -649,7 +649,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-CHUNK-RECORD-RUNTIME-001` | While serving: state only via the kernel, a hash only with its evidence; a page dirties only on a state or hash change and is written by its count or age (an evict's at once), in snapshot order, after the WAL is synced through the position it shows; G <= min(applied, dirty-from, WAL synced). | M3 Serving (chunk record runtime) | `core/storage/chunk_record_runtime.go` `chunkRecordRuntime.Apply`, `Due`, `WriteDue`, `WriteThrough`, `Flush`, `writeSegmentLocked` (`syncThrough`), `writeHeaderLocked` (`durable`) | `TestRecordRuntimeAppliesTheKernel`, `TestRecordRuntimeEvictWritesThePageFirst`, `TestRecordRuntimeSchedulePerPage`, `TestRecordRuntimeFlushIsLoadedBack`, `TestRecordRuntimeWriteThrough`, `TestRecordRuntimeAnUnchangedStateWritesNothing`, `TestRecordRuntimeHeaderMovesUnderWrites`, `TestRecordRuntimeEvictDuringAFlushLandsLast`, `TestRecordRuntimePageWritesFollowChangesNotSize`, `TestRecordRuntimePageWritersPublishInOrder`, `TestRecordRuntimeHashEvidence`, `TestRecordRuntimeCopiesItsInputs`, `TestRecordRuntimeAPageChangedAtOpenHoldsG` (`core/storage/chunk_record_runtime_test.go`); the WAL bound: `TestV11NoPageClaimsMoreThanTheDurableWAL`, `TestV11APageNeverShowsAWriteTheWALCanLose` (`core/storage/chunk_record_v11_review_test.go`, `chunk_record_v11_hold_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 via 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. It decides nothing; on v1.0 it 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 |
|
||||
| `INV-CHUNK-RECORD-V11-001` | On the draft v1.1 format a layer upgrades its store once at attach and opens from its record; a fill's page claims no local block before one durable mark (partial fills and later writes too); an evict clears the store's bits only after its absent page is durable, retries too. | M1 Opened, M3 Serving (draft v1.1 format) | `core/storage/chunk_record_open.go` `openChunkRecordV11`, `loadChunkRecordV11`, `markFills`; `core/storage/chunk_record_upgrade.go` `upgradeChunkRecordWith`; `core/storage/chunk_record_runtime.go` `holdFills`, `PersistSegmentOf`; `core/storage/chunk_record_shadow.go` `evict`; `core/storage/chunk_layer.go` `EvictChunk`, `Close` | `TestV11AttachUpgradesTheStoreOnce`, `TestV11ReopenJudgesAWriteAfterThePageAsChanged`, `TestV11CleanStopWritesOnlyTheDirtyPages`, `TestV11UpgradeRecoversFromACrashAtEachStep`, `TestV11DamagedPageIsRebuiltFromTheStoreBits`, `TestV11FillsAreMarkedInOneBatchBeforeTheirPagesClaimThem`, `TestV11EvictSurvivesARestart` (`core/storage/chunk_record_v11_test.go`); `TestV11CloseDuringTheUpgradeRefusesTheAttach`, `TestV11EvictWithoutItsAbsentPageClearsNothing`, `TestV11ParkedFillBatchCannotOverwriteAnEvict`, `TestV11MalformedLeftoverPresenceDoesNotRefuseTheAttach`, `TestV11FinalPageFailureIsTheCloseResult` (`core/storage/chunk_record_v11_review_test.go`); `TestV11PartialFillWaitsForTheDurableMark`, `TestV11WriteAfterAHeldFillKeepsTheHold`, `TestV11EvictRetryStillWritesItsAbsentPage` (`core/storage/chunk_record_v11_hold_test.go`); `TestV11AbsentChunkSurvivesALostHeader`, `TestV11LogOnlyWriteSurvivesTheUpgrade` (`core/storage/chunk_record_v11_upgrade_test.go`) | chunk-kernel/2; CoverageDurable row 199 (the WAL is durable through a published position) (not in this repository) | DORMANT |
|
||||
| `INV-CHUNK-FORMAT-LEVEL-001` | An attach raises a store to the v1.1 format only at the assigned format level 1 (absent = 0); at level 0 a store already on v1.1 is served only over a version-1 HEAD, reported, and refused typed over a version-0 HEAD. | M-format gate (holder) | `core/storage/chunk_v11_format.go` `attachFormat`; `core/storage/chunk_layer.go` `attachChunkLayerImpl`; `core/frontend/chunkstore/layout_remote.go` `SetHeadFormatV11`, `HeadV11` | `TestAttachFormatFollowsTheAssignedLevel`, `TestAttachAtLevelZeroOfAnUpgradedStore` (`core/storage/chunk_format_level_test.go`); `TestLayoutRemoteHeadFormatFollowsItsLayer` (`core/frontend/chunkstore/layout_manifest_size_test.go`) | none | ACTIVE |
|
||||
| `INV-CHUNK-FORMAT-LEVEL-001` | An attach raises a volume to v1.1 only at the assigned format level 1 (absent = 0); at level 0 it runs v1.1 only over a version-1 HEAD (reported), refuses a v1.1 store over a version-0 HEAD, and a v1.1 attach refuses a remote without the HEAD format. | M-format gate (holder) | `core/storage/chunk_v11_format.go` `attachLevelV11`, `levelZeroFormat`; `core/storage/chunk_layer.go` `attachChunkLayerImpl`; `core/frontend/chunkstore/layout/format_level.go` `checkFormatLevel` (in `runTransition`); `core/frontend/chunkstore/layout_remote.go` `SetHeadFormat`, `HeadV11`; `core/host/volume/host.go` `applyFact`; `core/frontend/durable/provider_layout.go` `attachFormatLevel` | `TestAttachFormatFollowsTheAssignedLevel`, `TestAttachAtLevelZeroOfAnUpgradedStore`, `TestAttachAtLevelZeroOfAV11HeadOverAnUnmarkedStore`, `TestAV11AttachRefusesARemoteWithoutTheHeadFormat`, `TestALevelOneCrashBeforeTheFirstCutReattachesAsV11` (`core/storage/chunk_format_level_test.go`); `TestLayoutRemoteHeadFormatFollowsItsLayer`, `TestALevelZeroCommitCannotRaiseHeadToVersionOne` (`core/frontend/chunkstore/layout_manifest_size_test.go`); `TestNoHeadWriteRaisesTheVersionBelowFormatLevelOne` (`core/frontend/chunkstore/layout/format_level_test.go`); `TestTheWrappedRemoteForwardsTheHeadFormatBothWays`, `TestAttachFormatLevelFromTheAssignment` (`core/frontend/durable/format_level_test.go`); `TestTheSelfAssignmentsFormatLevelReachesTheProjection` (`core/host/volume/format_level_test.go`) | none | ACTIVE |
|
||||
| `INV-CHUNK-FOREIGN-ROOT-FENCE-001` | A HEAD that moved past the holder's base without superseding it and is not its own proposal must keep the chunk root; one that changed it fences the layer (`errChunkForeignRoot`), so no chunk is held clean against a root that no longer names it. | M5 Commit (head conflict, settlement) | `core/storage/chunk_layer.go` `adoptHeadLocked` (from `captureLocked`, `SettleDetach`, `resolvePending`) | `TestShadowForeignRootWithoutSupersedeFences` (`core/storage/chunk_record_shadow_test.go`) | HeadWriters (only metadata writers move HEAD without superseding; not in this repository) | ACTIVE |
|
||||
| `INV-CHUNK-RECORD-PAYLOAD-001` | Persisting and loading a chunk record preserves every entry's state and hash, including entries on either side of a segment boundary. | M1 chunk record codec (caller not wired) | `core/storage/chunk_record.go` `encodeChunkRecordPage`, `decodeChunkRecordPage` | `TestRecordEntryPayloadRoundTripsAcrossSegments` (`core/storage/chunk_record_test.go`; state-zero and one-entry hash-drop controls) | Encoding fidelity; no state transition change | STUB |
|
||||
| `INV-CHUNK-COVERAGE-INIT-POSITION-001` | Coverage initialization rechecks the captured append position under the final store lock before publishing a fence or replacing live entries; a changed position refuses the candidate. | M1 coverage initialization | `core/storage/chunk_coverage.go` `InitializeChunkCoverage` | `TestChunkCoverageInitializationRefusesAnAppendDuringPagePreparation`, `TestChunkCoverageInitializationCaptureBarrierExcludesPublicWrites` (`core/storage/chunk_coverage_initialization_append_test.go`) | SlotFence.Publish; capture barrier remains the public-write exclusion | ACTIVE |
|
||||
@@ -1220,6 +1220,7 @@ Notes:
|
||||
| `INV-SNAPK-HEAD-GUARD-001` | A source scan refuses any other use of `UpdateHead`, a transition without its closure and interrupt tests, and any store remover other than the mark-gated Cleaner.removePlanned and the ordered DeleteVolume. | M9 every transition | `core/frontend/chunkstore/layout` (source scan of the package) | `TestGuard_WritersTransitionsAndRemovers`, `TestGuard_Controls` | CommitReach rows 65-70; CommitReach2 rows 71-75 (CPlan, CView, CIssueMark/LandMark, CIssueDel/LandDel; model-code trace) | ACTIVE |
|
||||
| `INV-SNAPK-HEAD-CODEC-001` | HEAD is canonical JSON with at most 10 snapshots (`MaxSnapshots`) and sorted unique dependents; unknown fields, non-canonical bytes and names that are not valid UTF-8 are refused at encode and decode, and the next HEAD is checked before it is written. | M9 every transition | `core/frontend/chunkstore/layout` `head.go` `Head.check`, `Head.Encode`, `DecodeHead` | `TestHead_GoldenEncodingRoundTrip`, `TestHead_Refusals`, `TestHead_RefusesInvalidUTF8` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-HEAD-V11-VERSION-001` | Any HEAD carrying a v1.1-only field (a manifest size, ext) is version 1, and a v1.1 commit writes version 1 whether or not it knows the manifest size; a version-0 HEAD with one is refused. | M-snapshot commit | `core/frontend/chunkstore/layout/commit.go` `withManifestBytes`; `core/frontend/chunkstore/layout/head.go` `check`, `checkExt`; `core/frontend/chunkstore/layout_remote.go` (`CommitRequest.V11`) | `TestCommitRecordsTheManifestSize` (`core/frontend/chunkstore/layout/head_version_test.go`); `TestACommitByChangeKeepsAnUnknownSizeUnknown` (`core/frontend/chunkstore/layout_manifest_size_test.go`) | none | ACTIVE |
|
||||
| `INV-SNAPK-HEAD-FORMAT-LEVEL-001` | No HEAD write raises HEAD from version 0 to version 1 below format level 1 (a writer's level absent = 0), whichever writer tries; a HEAD already at version 1 stays writable at any level. | M-snapshot commit | `core/frontend/chunkstore/layout/format_level.go` `checkFormatLevel`, `WithFormatLevel`; `core/frontend/chunkstore/layout/head.go` `runTransition`; `core/frontend/chunkstore/layout_remote.go` `atFormatLevel` | `TestNoHeadWriteRaisesTheVersionBelowFormatLevelOne` (`core/frontend/chunkstore/layout/format_level_test.go`); `TestALevelZeroCommitCannotRaiseHeadToVersionOne` (`core/frontend/chunkstore/layout_manifest_size_test.go`) | none | ACTIVE |
|
||||
| `INV-SNAPK-BEGIN-001` | Begin opens snap(s) only for the holder at HEAD's epoch and only from idle; a re-run of the open session writes nothing; killed at its write and re-run, it ends in snap(s) at one generation step. | M9 idle → snap | `core/frontend/chunkstore/layout` `head.go` `Head.Begin`, `RunBegin` | `TestBegin_Closure`, `TestRunBegin_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-ABORT-001` | Abort closes the holder's own snap(s) and changes nothing else; after its own crash a holder rolls the open session back before beginning another; over idle Abort writes nothing and its success never says whether the work was committed. | M9 snap → idle (Abort) | `core/frontend/chunkstore/layout` `head.go` `Head.Abort`, `RunAbort`; `core/frontend/durable/provider_layout.go` `settleLayoutStop` | `TestLayoutStopAbortMustConfirmItsOutcome`, `TestLayoutRemote_AbortOpenSessionDoesNotWaitForAHeldCommit`, `TestLayoutRemote_AbortOpenSessionFencesAForeignHead`, `TestLayoutRemoteSessionFieldSites`, `TestAbort_Closure`, `TestAbort_IdleMeansNoActivityRemains`, `TestAbort_RollBackAfterOwnCrash`, `TestRunAbort_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-COMMIT-REACH-001` | A commit never names an unwritten object: before its HEAD update it finds present, written by its session or adopted from an earlier one of this volume, the own chunks new against HEAD's current root, every segment and the root; unchanged and foreign chunks are not looked up. | M9 snap → idle (Commit) | `core/frontend/chunkstore/layout` `commit.go` `RunCommit`, `CheckCommitObjects`, `Head.Commit`; the lookups run with the cut's budget before the bounded HEAD update (`layout_remote.go` `LayoutRemote.CheckCommit`, called by `core/storage/chunk_layer.go`), and the CAS skips them only for the (session, root) checked | `TestCommit_Closure`, `TestRunCommit_LooksUpOnlyWhatIsNew`, `TestRunCommit_RefusesUnwrittenObjects`, `TestRunCommit_StaleBaseAndLookupFailure`, `TestRunCommit_AfterAnEmptyPublishedRoot`, `TestRunCommit_InterruptAtEveryStep`; its verification is bounded parallel and stays all-or-nothing: `TestCommitVerifiesManyNewChunksWithinTheBudget`, `TestADetachingCommitOfManyNewChunksCompletesWithinTheBudget`, `TestCommitRefusesWhenOneOfManyNewChunksIsNotPrepared`, `TestCommitLookupsNeverExceedTheCap`, `TestACancelledCommitStopsJoinsAndWritesNothing`, `TestTheEarliestFailureByPositionDecidesTheError` (`commit_verify_scale_test.go`, `commit_verify_controls_test.go`); outside the 2 s update: `TestCutCommitsWhenItsObjectCheckOutlastsTheHeadUpdate`, `TestCASSkipsTheLookupsCheckedForItsSessionAndRoot`, `TestCASWithNoPassedCheckDoesTheLookups`, `TestCASAfterACheckOfAnotherRootDoesTheLookups`, `TestBeginCleanBetweenTheCheckAndTheUpdateIsBusy`, `TestAPreCheckThatFindsAChunkMissingEndsWithNoLookupInTheCAS` (`core/frontend/chunkstore/layout_commit_check_budget_test.go`); `TestObjectsCheckedIsWrittenOnlyByCASHead`, `TestCASAfterAnAbortAndANewSessionAtTheSameRootDoesTheLookups`, `TestCommitPendingSnapshotLooksUpTheRootAndSegments`, `TestMetadataRetryLooksUpOnlyWithoutAPassedCheck` (`core/frontend/chunkstore/layout_commit_check_guards_test.go`); through the provider's wrapped remote: `TestProviderCutCommitsWhenItsObjectCheckOutlastsTheHeadUpdate`, `TestProviderWrappedRemoteKeepsTheLayoutRemotesOptionalInterfaces` (`core/frontend/durable/commit_check_budget_test.go`); `TestLayoutRemoteUploadFinishedAfterSessionEndCannotCommit` (`core/frontend/chunkstore/layout_upload_concurrency_test.go`); also in `core/frontend/chunkstore/layout/commit_test.go` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
|
||||
@@ -19,6 +19,7 @@ The volume's authority and health projection. Go type `volume.StatusProjection`.
|
||||
| `Epoch` | uint64 | the authority epoch of the current assignment |
|
||||
| `EndpointVersion` | uint64 | the assignment's endpoint version within the epoch |
|
||||
| `Healthy` | bool | the replica may serve I/O at this epoch |
|
||||
| `FormatLevel` | uint32 | FormatLevel is the cluster format level the master's assignment carries (0 when absent: an older master, or none yet): an attach may raise a store to the v1.1 format only at level 1. |
|
||||
| `Version` | string | Version is the build revision plus modified flag, matching master product_revision. Unknown provenance does not prove that two builds are equal. |
|
||||
| `Memory` | object | Memory is the process's memory use at the time of the request. |
|
||||
| `Memory.HeapAllocBytes` | uint64 | Go heap bytes in live objects (runtime.MemStats.HeapAlloc) |
|
||||
@@ -322,6 +323,7 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
|
||||
| `Volumes[].Chunk.Stats.UpgradePass.Superseded` | uint64 | Superseded counts chunks written during their own compare (in this process): not hashed, not counted as compared; each is dirty and the next cut takes it as any written chunk. |
|
||||
| `Volumes[].Chunk.Stats.UpgradePass.Outcome` | string | why a failed pass stopped; while the pass has not ended a cut, snapshot, backup or sealing detach is refused with code in_progress (omitted when empty) |
|
||||
| `Volumes[].Chunk.Stats.FormatLevelBehindVolume` | bool | FormatLevelBehindVolume: attached at format level 0 to a store and HEAD already on v1.1 (format_level_behind_volume): served as v1.1. |
|
||||
| `Volumes[].Chunk.Stats.FormatV11` | bool | FormatV11: the layer runs the v1.1 store format (decided at attach from its format level and the store): what a gate asserts it measured. |
|
||||
| `Volumes[].Chunk.Stats.BarrierOverBound` | uint64 | BarrierOverBound counts cuts whose barrier copied more than the bound after the staging rounds. |
|
||||
| `Volumes[].Chunk.Stats.AbsentChunks` | int | AbsentChunks is the number of HEAD-named chunks still absent with a block not local (what HydrateAll would still fetch); 0 = fully local. |
|
||||
| `Volumes[].Chunk.Stats.COWSpillCap` | int64 | COWSpillCap is the last cut's side-file cap in bytes, read once per cut; COWSpillCapReason is why it is 0, when the free space made it so: no_room_to_cut (half the free space is within the 1 GiB reserve) or free_space_unreadable (the free space could not be read). |
|
||||
|
||||
Reference in new issue
Block a user