mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
Merge pull request #867 from seaweedfs/fix/volume-directory-collision
fix: recover pending volume creates from id8 directory collisions
This commit is contained in:
commit
e09cdeb2f0
13 files changed
+624
-8
No files matched your search
@@ -19,6 +19,7 @@ import (
|
||||
// master's volume record, never from a name given plus an id read from
|
||||
// that same directory. A new site fails until it is classified here.
|
||||
var deleteSites = map[string]string{
|
||||
"core/frontend/chunkstore/layout_create.go LayoutStore.CreateVolumeRecord -> VolumeDir": "validation only after a rejected exclusive create: a valid full foreign VOLUME must name the already selected name/id8 directory; TestCreateVolumeExclusiveCollisionRedraws; no directory selection or removal",
|
||||
"core/frontend/chunkstore/startup_head_probe.go BCatalog.cleanStartupProbes -> DeleteEntry": "only exact reserved 32-hex probe directories observed before the full active-probe grace; nonrecursive HEAD and empty directory deletes, no volume directory (TestConditionalHeadNextStartCleansCrashLeftovers)",
|
||||
"core/frontend/chunkstore/startup_head_probe.go BCatalog.checkConditionalHead -> DeleteEntry": "only the disposable HEAD and empty random probe directory after successful exclusive create; no volume directory is used (TestCatalogStartupRequiresWrongGenerationHeadRefusal)",
|
||||
"cmd/sw-block/chunk_verify.go chunkVerify -> VolumeDir": "master-resolved full id and requested name; offline form accepts an explicit directory without discovering an identity",
|
||||
|
||||
@@ -16,6 +16,11 @@ type NewVolumeStore interface {
|
||||
CreateVolumeRecord(ctx context.Context, v Volume) error
|
||||
}
|
||||
|
||||
// ErrDirectoryCollision means an exclusive VOLUME create found a valid,
|
||||
// different full identity in the same name/id8 directory. Only a pending
|
||||
// ordinary create may redraw its identity; readers still refuse the mismatch.
|
||||
var ErrDirectoryCollision = fmt.Errorf("%w: volume directory collision", ErrIdentity)
|
||||
|
||||
// Unclaimed is the first HEAD of a volume: its id, epoch 0, no holder, no
|
||||
// claim id, idle, live, position 0, and current (nil for a new volume, the
|
||||
// copied root for a restore target). The first Start claims it from a
|
||||
|
||||
+3
-1
@@ -86,7 +86,9 @@ func TestVolumeWriterRepositorySites(t *testing.T) {
|
||||
"core/frontend/chunkstore/layout/read.go VolumeID VolumeName": 1,
|
||||
"core/frontend/chunkstore/layout/verify.go volumeID VolumeName": 1,
|
||||
"core/frontend/chunkstore/layout_create.go ReadVolumeRecord VolumeName": 1,
|
||||
"core/frontend/chunkstore/layout_create.go CreateVolumeRecord VolumeName": 1,
|
||||
// One exclusive create plus one read-only collision classification;
|
||||
// TestDirectoryCollisionIsOnlyAnExclusiveCreateRefusal pins the latter.
|
||||
"core/frontend/chunkstore/layout_create.go CreateVolumeRecord VolumeName": 2,
|
||||
}
|
||||
got := map[string]int{}
|
||||
root := filepath.Clean("../../../..")
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package chunkstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDirectoryCollisionIsOnlyAnExclusiveCreateRefusal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
f := NewMemFiler()
|
||||
cat, _ := NewBCatalog(f, newFakeBlobs(), "/blocks")
|
||||
v := VolumeRef{Name: "v", ID: layout.VolumeID{1}}
|
||||
foreign := v
|
||||
foreign.ID[15] = 2
|
||||
g := layout.Geometry{SizeBytes: 1 << 20, BlockSize: 4096, ChunkBytes: 4 << 20}
|
||||
if _, e := cat.CreateVolume(ctx, foreign, g); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
st, _ := cat.Store(v)
|
||||
if _, _, e := st.ReadVolumeRecord(ctx); !errors.Is(e, layout.ErrIdentity) || errors.Is(e, layout.ErrDirectoryCollision) {
|
||||
t.Fatalf("read allowed redraw: %v", e)
|
||||
}
|
||||
if _, e := cat.CreateVolume(ctx, v, g); !errors.Is(e, layout.ErrDirectoryCollision) || !errors.Is(e, layout.ErrIdentity) {
|
||||
t.Fatalf("collision not classified: %v", e)
|
||||
}
|
||||
// A wrong full identity that does not belong in the selected id8 path is
|
||||
// corruption, not evidence that a new random directory would heal it.
|
||||
wrong := foreign
|
||||
wrong.ID[0] = 3
|
||||
raw, e := (layout.Volume{ID: wrong.ID, Name: wrong.Name, Format: layout.VolumeFormat, Geometry: g}).Encode()
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
entry, e := f.LookupEntry(ctx, "/blocks/"+v.Dir(), layout.VolumeName)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
entry.Content = raw
|
||||
if e = f.UpdateEntry(ctx, "/blocks/"+v.Dir(), entry, nil); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = cat.CreateVolume(ctx, v, g); !errors.Is(e, layout.ErrIdentity) || errors.Is(e, layout.ErrDirectoryCollision) {
|
||||
t.Fatalf("corruption allowed redraw: %v", e)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -94,6 +95,19 @@ func (s *LayoutStore) CreateVolumeRecord(ctx context.Context, v layout.Volume) e
|
||||
e.Extended = map[string][]byte{layoutKind: []byte("volume"), layoutVolume: []byte(s.id.String())}
|
||||
err = s.f.CreateEntry(ctx, s.root, e, true)
|
||||
if errors.Is(err, ErrExists) {
|
||||
// Classify only the rejected exclusive VOLUME create, before any
|
||||
// HEAD write. An ordinary read keeps the full-identity refusal.
|
||||
existing, readErr := s.f.LookupEntry(ctx, s.root, layout.VolumeName)
|
||||
if readErr != nil {
|
||||
return readErr
|
||||
}
|
||||
got, decodeErr := layout.DecodeVolume(existing.Content)
|
||||
if decodeErr != nil {
|
||||
return fmt.Errorf("%w: VOLUME: %v", layout.ErrCorrupt, decodeErr)
|
||||
}
|
||||
if got.ID != v.ID && got.Name == v.Name && layout.VolumeDir(got.Name, got.ID) == path.Base(s.root) {
|
||||
return layout.ErrDirectoryCollision
|
||||
}
|
||||
return layout.ErrExists
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type safetyFiler struct {
|
||||
*chunkstore.MemFiler
|
||||
entries map[string][]byte
|
||||
writes int
|
||||
}
|
||||
|
||||
func (f *safetyFiler) CreateEntry(c context.Context, d string, e *filerpb.Entry, x bool) error {
|
||||
err := f.MemFiler.CreateEntry(c, d, e, x)
|
||||
if err == nil {
|
||||
b, _ := proto.MarshalOptions{Deterministic: true}.Marshal(e)
|
||||
f.entries[d+"/"+e.Name] = b
|
||||
f.writes++
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (f *safetyFiler) UpdateEntry(c context.Context, d string, e *filerpb.Entry, x map[string][]byte) error {
|
||||
err := f.MemFiler.UpdateEntry(c, d, e, x)
|
||||
if err == nil {
|
||||
b, _ := proto.MarshalOptions{Deterministic: true}.Marshal(e)
|
||||
f.entries[d+"/"+e.Name] = b
|
||||
f.writes++
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (f *safetyFiler) DeleteEntry(c context.Context, d, n string, x map[string][]byte) error {
|
||||
err := f.MemFiler.DeleteEntry(c, d, n, x)
|
||||
if err == nil {
|
||||
delete(f.entries, d+"/"+n)
|
||||
f.writes++
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
type safetyBlobs struct {
|
||||
data map[string][]byte
|
||||
puts int
|
||||
}
|
||||
|
||||
func (b *safetyBlobs) Put(_ context.Context, d []byte) (string, error) {
|
||||
b.puts++
|
||||
id := fmt.Sprint(b.puts)
|
||||
b.data[id] = append([]byte(nil), d...)
|
||||
return id, nil
|
||||
}
|
||||
func (b *safetyBlobs) Get(_ context.Context, id string) ([]byte, error) {
|
||||
d, ok := b.data[id]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("missing %s", id)
|
||||
}
|
||||
return append([]byte(nil), d...), nil
|
||||
}
|
||||
|
||||
type safetyLease struct{}
|
||||
|
||||
func (safetyLease) OldLeaseEnded(context.Context, uint64) error { return nil }
|
||||
func safetyDigest(m map[string][]byte) string {
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
h := sha256.New()
|
||||
for _, k := range keys {
|
||||
fmt.Fprintf(h, "%d:%s:%d:", len(k), k, len(m[k]))
|
||||
h.Write(m[k])
|
||||
}
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
||||
func TestCollisionExistingVolumeSafety(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
defer cancel()
|
||||
h := newTestMaster(t, t.TempDir())
|
||||
defer closeTestMaster(t, h)
|
||||
h.cfg.WorkspaceRPC = true
|
||||
f := &safetyFiler{MemFiler: chunkstore.NewMemFiler(), entries: map[string][]byte{}}
|
||||
b := &safetyBlobs{data: map[string][]byte{}}
|
||||
cat, err := chunkstore.NewBCatalog(f, b, "/collision")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var foreign chunkstore.VolumeRef
|
||||
var g layout.Geometry
|
||||
var beforeMeta, beforeData string
|
||||
var beforeWrites, beforePuts int
|
||||
me := layout.HolderID{Epoch: 1, Holder: "existing-holder", ClaimID: "existing-claim"}
|
||||
attach := func(name string) (*storage.WALStore, storage.ChunkLayer) {
|
||||
t.Helper()
|
||||
s, e := storage.CreateWALStoreWithOptions(filepath.Join(t.TempDir(), name), uint32(g.SizeBytes/uint64(g.BlockSize)), int(g.BlockSize), storage.WALStoreOptions{ChunkBlocks: uint32(g.ChunkBytes / uint64(g.BlockSize))})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.Recover(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
r, e := chunkstore.NewLayoutRemote(cat, foreign, me)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
l, e := storage.AttachChunkLayer(s, r, storage.ChunkLayerConfig{ChunkBlocks: uint32(g.ChunkBytes / uint64(g.BlockSize)), Epoch: me.Epoch, Holder: me.Holder, FreshFromHead: true})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
return s, l
|
||||
}
|
||||
want := bytes.Repeat([]byte{0xa7}, 4096)
|
||||
attempts := 0
|
||||
h.cfg.LayoutCreateVolume = func(c context.Context, spec lifecycle.VolumeSpec) error {
|
||||
id, e := layout.ParseVolumeID(spec.LayoutID)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
ref := chunkstore.VolumeRef{Name: spec.VolumeID, ID: id}
|
||||
attempts++
|
||||
if attempts == 1 {
|
||||
foreign = ref
|
||||
foreign.ID[15] ^= 1
|
||||
g = layout.Geometry{SizeBytes: spec.SizeBytes, BlockSize: spec.BlockSize, ChunkBytes: spec.ChunkBytes}
|
||||
if _, e = cat.CreateVolume(c, foreign, g); e != nil {
|
||||
return e
|
||||
}
|
||||
st, _ := cat.Store(foreign)
|
||||
if _, e = layout.Start(c, st, safetyLease{}, layout.HolderID{Epoch: 1, Holder: me.Holder}, layout.LocalRoot{Geometry: g, ClaimID: me.ClaimID, Fresh: true, CanStartFrom: func(layout.Head) error { return nil }}); e != nil {
|
||||
return e
|
||||
}
|
||||
s, l := attach("seed")
|
||||
if _, e = s.Write(0, want); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.Sync(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = l.Capture(ctx); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if e = s.Close(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
beforeMeta = safetyDigest(f.entries)
|
||||
beforeData = safetyDigest(b.data)
|
||||
beforeWrites = f.writes
|
||||
beforePuts = b.puts
|
||||
}
|
||||
_, e = cat.CreateVolume(c, ref, g)
|
||||
return e
|
||||
}
|
||||
req := &control.CreateVolumeRequest{VolumeId: "v", SizeBytes: 1 << 20, ReplicationFactor: 1}
|
||||
for i := 0; i < 1; i++ {
|
||||
if _, e := newServices(h).CreateVolume(ctx, req); e == nil {
|
||||
t.Fatal("collision unexpectedly healed; reassess witness")
|
||||
}
|
||||
}
|
||||
if safetyDigest(f.entries) != beforeMeta || safetyDigest(b.data) != beforeData || f.writes != beforeWrites || b.puts != beforePuts {
|
||||
t.Fatalf("SAFETY FAILURE metadata/data changed: writes %d->%d puts %d->%d", beforeWrites, f.writes, beforePuts, b.puts)
|
||||
}
|
||||
head, found, e := cat.ReadHead(ctx, foreign)
|
||||
if e != nil || !found || head.Activity.Kind != layout.ActIdle {
|
||||
t.Fatalf("HEAD lock/activity left: %+v %v", head, e)
|
||||
}
|
||||
t.Logf("BYTE_IDENTICAL metadata_sha256=%s blobs_sha256=%s successful_mutations=0 puts=0 directory=%s activity=idle", beforeMeta, beforeData, foreign.Dir())
|
||||
s, l := attach("after-collision")
|
||||
defer s.Close()
|
||||
got, e := s.Read(0)
|
||||
if e != nil || !bytes.Equal(got, want) {
|
||||
t.Fatalf("reattach/read old data failed: %v", e)
|
||||
}
|
||||
next := bytes.Repeat([]byte{0x3c}, 4096)
|
||||
if _, e = s.Write(1, next); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.Sync(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = l.Capture(ctx); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
got, e = s.Read(1)
|
||||
if e != nil || !bytes.Equal(got, next) {
|
||||
t.Fatalf("serve new write/read failed: %v", e)
|
||||
}
|
||||
t.Log("ATTACH_AND_SERVE_PASS old nonzero data read; new write synced, cut committed, read back; no lock left")
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
)
|
||||
|
||||
type collisionBlobs struct{}
|
||||
|
||||
func (collisionBlobs) Put(context.Context, []byte) (string, error) {
|
||||
return "", errors.New("unexpected payload upload")
|
||||
}
|
||||
func (collisionBlobs) Get(context.Context, string) ([]byte, error) {
|
||||
return nil, errors.New("unexpected payload read")
|
||||
}
|
||||
|
||||
// A full-id mismatch in an exclusively-created VOLUME is a directory collision,
|
||||
// not a replay. The next create attempt must use a newly minted directory.
|
||||
func TestCreateVolumeExclusiveCollisionRedraws(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
h := newTestMaster(t, t.TempDir())
|
||||
defer closeTestMaster(t, h)
|
||||
h.cfg.WorkspaceRPC = true
|
||||
cat, err := chunkstore.NewBCatalog(chunkstore.NewMemFiler(), collisionBlobs{}, "/collision")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var first, foreign chunkstore.VolumeRef
|
||||
var old layout.Volume
|
||||
attempts := 0
|
||||
h.cfg.LayoutCreateVolume = func(ctx context.Context, spec lifecycle.VolumeSpec) error {
|
||||
id, err := layout.ParseVolumeID(spec.LayoutID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ref := chunkstore.VolumeRef{Name: spec.VolumeID, ID: id}
|
||||
g := layout.Geometry{SizeBytes: spec.SizeBytes, BlockSize: spec.BlockSize, ChunkBytes: spec.ChunkBytes}
|
||||
attempts++
|
||||
if attempts == 1 {
|
||||
first = ref
|
||||
foreign = ref
|
||||
foreign.ID[15] ^= 1
|
||||
if _, err := cat.CreateVolume(ctx, foreign, g); err != nil {
|
||||
return err
|
||||
}
|
||||
old, err = cat.ReadVolume(ctx, foreign)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = cat.CreateVolume(ctx, ref, g)
|
||||
return err
|
||||
}
|
||||
req := &control.CreateVolumeRequest{VolumeId: "v", SizeBytes: 1 << 20, ReplicationFactor: 1}
|
||||
// A retry is allowed, but it must heal the collision rather than stay stuck.
|
||||
resp, err := newServices(h).CreateVolume(ctx, req)
|
||||
if err != nil {
|
||||
resp, err = newServices(h).CreateVolume(ctx, req)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("exclusive-create collision did not redraw: attempts=%d first=%s err=%v", attempts, first.ID, err)
|
||||
}
|
||||
id, err := layout.ParseVolumeID(resp.GetLayoutId())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
next := chunkstore.VolumeRef{Name: "v", ID: id}
|
||||
if !resp.GetStoreReady() || id == first.ID || next.Dir() == first.Dir() {
|
||||
t.Fatalf("collision reused identity/directory: first=%s next=%s ready=%v", first.ID, id, resp.GetStoreReady())
|
||||
}
|
||||
got, err := cat.ReadVolume(ctx, foreign)
|
||||
if err != nil || got != old {
|
||||
t.Fatalf("redraw altered the colliding volume: %v %v", got, err)
|
||||
}
|
||||
replay, err := newServices(h).CreateVolume(ctx, req)
|
||||
if err != nil || replay.GetLayoutId() != id.String() {
|
||||
t.Fatalf("settled identity changed on replay: %v %v", replay, err)
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"github.com/seaweedfs/seaweed-block/core/auth"
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/lifecycleclient"
|
||||
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
||||
"github.com/seaweedfs/seaweed-block/core/ops"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/lifecycleclient"
|
||||
"github.com/seaweedfs/seaweed-block/core/storeident"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -241,6 +241,15 @@ func (h *Host) createLifecycleVolume(ctx context.Context, spec lifecycle.VolumeS
|
||||
}
|
||||
} else {
|
||||
createErr = h.cfg.LayoutCreateVolume(ctx, rec.Spec)
|
||||
if errors.Is(createErr, layout.ErrDirectoryCollision) {
|
||||
// The rejected exclusive create wrote nothing to the colliding
|
||||
// volume. Persist a fresh directory before the next RPC retries;
|
||||
// ordinary store errors keep their original identity for replay.
|
||||
if _, err := h.lifecycle.Volumes.RedrawPendingLayoutID(rec.Spec.VolumeID, rec.Spec.LayoutID); err != nil {
|
||||
return lifecycle.VolumeRecord{}, fmt.Errorf("%w: directory collision; replacement not settled: %w", errLayoutStoreNotReady, err)
|
||||
}
|
||||
return lifecycle.VolumeRecord{}, fmt.Errorf("%w: directory collision; a fresh identity is recorded; retry", errLayoutStoreNotReady)
|
||||
}
|
||||
}
|
||||
if createErr != nil {
|
||||
return lifecycle.VolumeRecord{}, fmt.Errorf("%w: %w", errLayoutStoreNotReady, createErr)
|
||||
|
||||
@@ -16,6 +16,7 @@ func TestLayoutIdentityWriterAndReaders(t *testing.T) {
|
||||
// or a lifecycle record; its RPC containment is tested at catalog startup.
|
||||
mintSites := map[string]string{
|
||||
"core/lifecycle/store.go CreateVolume": "durable lifecycle volume identity",
|
||||
"core/lifecycle/store.go RedrawPendingLayoutID": "only a rejected unplaced ordinary create; TestRedrawPendingLayoutID and TestCreateVolumeExclusiveCollisionRedraws",
|
||||
"core/frontend/chunkstore/startup_head_probe.go checkConditionalHead": "disposable HEAD only, exclusive create in its random probe namespace; TestCatalogStartupRequiresWrongGenerationHeadRefusal",
|
||||
}
|
||||
seenMints := map[string]bool{}
|
||||
@@ -24,6 +25,8 @@ func TestLayoutIdentityWriterAndReaders(t *testing.T) {
|
||||
"core/lifecycle/store.go volumeSpecsCompatible": true,
|
||||
"core/lifecycle/store.go validateSpec": true,
|
||||
"core/lifecycle/store.go MarkStoreReady": true,
|
||||
"core/lifecycle/store.go RedrawPendingLayoutID": true,
|
||||
"core/lifecycle/store.go settlePendingLayoutIDLocked": true,
|
||||
"core/lifecycle/workload_plan.go PlanBlockVolumeWorkloads": true,
|
||||
"core/host/master/services.go lifecycleVolumeResponse": true,
|
||||
"core/host/master/services.go CreateVolume": true,
|
||||
@@ -127,11 +130,14 @@ func TestLayoutIdentityWriterAndReaders(t *testing.T) {
|
||||
// Adding a new reader or writer requires a binding probe at that site.
|
||||
func TestRestoreSourceIdentitySites(t *testing.T) {
|
||||
want := map[string]bool{
|
||||
"core/lifecycle/store.go CreateVolume": true,
|
||||
"core/lifecycle/store.go volumeSpecsCompatible": true,
|
||||
"core/lifecycle/store.go validateSpec": true,
|
||||
"core/host/master/services.go CreateVolume": true,
|
||||
"core/host/master/services.go createLifecycleVolume": true,
|
||||
// Restore records are excluded; TestRedrawPendingLayoutID probes both paths.
|
||||
"core/lifecycle/store.go RedrawPendingLayoutID": true,
|
||||
"core/lifecycle/store.go settlePendingLayoutIDLocked": true,
|
||||
"core/lifecycle/store.go CreateVolume": true,
|
||||
"core/lifecycle/store.go volumeSpecsCompatible": true,
|
||||
"core/lifecycle/store.go validateSpec": true,
|
||||
"core/host/master/services.go CreateVolume": true,
|
||||
"core/host/master/services.go createLifecycleVolume": true,
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
root := filepath.Join("..", "..")
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package lifecycle
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRedrawPendingLayoutID(t *testing.T) {
|
||||
if os.Getenv("SWB_REDRAW_CHILD") != "1" {
|
||||
cmd := exec.Command(os.Args[0], "-test.run=^TestRedrawPendingLayoutID$", "-test.v")
|
||||
cmd.Env = append(os.Environ(), "SWB_REDRAW_CHILD=1")
|
||||
if out, e := cmd.CombinedOutput(); e != nil {
|
||||
t.Fatalf("child: %v\n%s", e, out)
|
||||
}
|
||||
return
|
||||
}
|
||||
hooks := &durableRecordHooks{}
|
||||
if runtime.GOOS == "windows" {
|
||||
hooks.dirSync = func(string) error { return nil }
|
||||
}
|
||||
durableRecordHooksForTest.Store(hooks)
|
||||
defer durableRecordHooksForTest.Store(nil)
|
||||
s, e := OpenFileStore(t.TempDir())
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
spec := VolumeSpec{VolumeID: "v", SizeBytes: 1 << 20, ReplicationFactor: 1}
|
||||
old, e := s.CreateVolume(spec)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.RedrawPendingLayoutID("v", "00000000000000000000000000000001"); !errors.Is(e, ErrVolumeConflict) {
|
||||
t.Fatalf("stale ID accepted: %v", e)
|
||||
}
|
||||
// A lost directory-sync reply after rename must settle the replacement
|
||||
// from disk, even though the in-memory record still has the rejected ID.
|
||||
fail := true
|
||||
hooks.dirSync = func(string) error {
|
||||
if fail {
|
||||
return errors.New("lost directory sync")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if _, e = s.RedrawPendingLayoutID("v", old.Spec.LayoutID); e == nil {
|
||||
t.Fatal("sync failure hidden")
|
||||
}
|
||||
cur, _ := s.GetVolume("v")
|
||||
if cur != old {
|
||||
t.Fatal("uncertain replacement published")
|
||||
}
|
||||
raw, e := os.ReadFile(s.path("v"))
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
var disk VolumeRecord
|
||||
if e = json.Unmarshal(raw, &disk); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
fail = false
|
||||
// Exercise the public retry path, including metadata enrichment. It
|
||||
// must settle disk B before a metadata put could overwrite it with A.
|
||||
retry := spec
|
||||
retry.PVCName, retry.PVName = "claim", "pv"
|
||||
public, retryErr := s.CreateVolume(retry)
|
||||
if retryErr != nil || public.Spec.LayoutID != disk.Spec.LayoutID || public.Spec.PVCName != "claim" || public.Spec.PVName != "pv" {
|
||||
t.Fatalf("public retry lost disk replacement: disk=%s public=%+v err=%v", disk.Spec.LayoutID, public, retryErr)
|
||||
}
|
||||
// Re-enter the direct method with its current ID for a separate
|
||||
// replacement; the stale original ID must no longer be admitted.
|
||||
if _, e = s.RedrawPendingLayoutID("v", old.Spec.LayoutID); !errors.Is(e, ErrVolumeConflict) {
|
||||
t.Fatalf("settled replacement accepted stale rejected ID: %v", e)
|
||||
}
|
||||
got := public
|
||||
if got.Spec.LayoutID[:8] == old.Spec.LayoutID[:8] {
|
||||
t.Fatal("replacement reused directory")
|
||||
}
|
||||
reopened, e := OpenFileStore(s.dir)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
again, e := reopened.CreateVolume(spec)
|
||||
if e != nil || again != got {
|
||||
t.Fatalf("restart reminted: %+v %v", again, e)
|
||||
}
|
||||
if _, e = s.MarkStoreReady("v", got.Spec.LayoutID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.RedrawPendingLayoutID("v", got.Spec.LayoutID); !errors.Is(e, ErrVolumeConflict) {
|
||||
t.Fatalf("ready identity redrawn: %v", e)
|
||||
}
|
||||
spec.VolumeID = "attached"
|
||||
attached, e := s.CreateVolume(spec)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.AttachVolume("attached", "host"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.RedrawPendingLayoutID("attached", attached.Spec.LayoutID); !errors.Is(e, ErrVolumeConflict) {
|
||||
t.Fatalf("attached identity redrawn: %v", e)
|
||||
}
|
||||
spec.VolumeID = "restore"
|
||||
spec.SourceVolume = "source"
|
||||
spec.SourceLayoutID = got.Spec.LayoutID
|
||||
spec.SourceSnapshot = "snap"
|
||||
spec.CreateRequestID = "request"
|
||||
restore, e := s.CreateVolume(spec)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if _, e = s.RedrawPendingLayoutID("restore", restore.Spec.LayoutID); !errors.Is(e, ErrVolumeConflict) {
|
||||
t.Fatalf("restore identity redrawn: %v", e)
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,16 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) {
|
||||
if !volumeSpecsCompatible(existing.Spec, spec) {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
// A previous collision redraw may have reached disk but lost its
|
||||
// directory-sync reply. Settle it before enriching cached metadata.
|
||||
var err error
|
||||
existing, err = s.settlePendingLayoutIDLocked(existing)
|
||||
if err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
if !volumeSpecsCompatible(existing.Spec, spec) {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
merged := existing
|
||||
merged.Spec = mergeVolumeSpecMetadata(existing.Spec, spec)
|
||||
if merged.Spec != existing.Spec {
|
||||
@@ -205,6 +215,86 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) {
|
||||
return rec, nil
|
||||
}
|
||||
|
||||
// RedrawPendingLayoutID replaces only an unplaced ordinary create's rejected
|
||||
// identity. The caller must have proved an exclusive VOLUME directory collision.
|
||||
// A replacement whose directory-sync reply was lost is settled, never reminted.
|
||||
func (s *FileStore) RedrawPendingLayoutID(volumeID, rejectedID string) (VolumeRecord, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
rec, ok := s.records[volumeID]
|
||||
if !ok {
|
||||
return VolumeRecord{}, ErrVolumeNotFound
|
||||
}
|
||||
if rec.Spec.LayoutID != rejectedID || rec.StoreReady || rec.AttachedTo != "" || rec.Spec.SourceVolume != "" || rec.Spec.SourceLayoutID != "" || rec.Spec.SourceSnapshot != "" || rec.Spec.CreateRequestID != "" {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
settled, err := s.settlePendingLayoutIDLocked(rec)
|
||||
if err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
if settled.Spec.LayoutID != rejectedID {
|
||||
return settled, nil
|
||||
}
|
||||
disk := settled
|
||||
if disk.Spec.LayoutID == rejectedID {
|
||||
id, err := layout.NewVolumeID()
|
||||
if err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
if id.String()[:8] == rejectedID[:8] {
|
||||
return VolumeRecord{}, fmt.Errorf("lifecycle: replacement repeats the rejected directory; retry")
|
||||
}
|
||||
disk.Spec.LayoutID = id.String()
|
||||
}
|
||||
if err := s.putLocked(disk); err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
s.records[volumeID] = disk
|
||||
s.publishLocked()
|
||||
return disk, nil
|
||||
}
|
||||
|
||||
// settlePendingLayoutIDLocked reconciles only an uncertain pending identity
|
||||
// replacement, before either a redraw or public metadata enrichment can write.
|
||||
func (s *FileStore) settlePendingLayoutIDLocked(rec VolumeRecord) (VolumeRecord, error) {
|
||||
if rec.StoreReady || rec.AttachedTo != "" || rec.Spec.SourceVolume != "" || rec.Spec.SourceLayoutID != "" || rec.Spec.SourceSnapshot != "" || rec.Spec.CreateRequestID != "" {
|
||||
return rec, nil
|
||||
}
|
||||
raw, err := os.ReadFile(s.path(rec.Spec.VolumeID))
|
||||
if err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
var disk VolumeRecord
|
||||
if err := json.Unmarshal(raw, &disk); err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
if disk.Spec.LayoutID == rec.Spec.LayoutID {
|
||||
return rec, nil
|
||||
}
|
||||
id, err := layout.ParseVolumeID(disk.Spec.LayoutID)
|
||||
if err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
// Nothing except the identity may differ in an uncertain redraw.
|
||||
disk.Spec.LayoutID = rec.Spec.LayoutID
|
||||
if disk != rec {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
if _, err := layout.ParseVolumeID(rec.Spec.LayoutID); err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
if id.String()[:8] == rec.Spec.LayoutID[:8] {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
disk.Spec.LayoutID = id.String()
|
||||
if err := s.putLocked(disk); err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
s.records[rec.Spec.VolumeID] = disk
|
||||
s.publishLocked()
|
||||
return disk, nil
|
||||
}
|
||||
|
||||
// MarkStoreReady publishes the durable placement hint after the filer has
|
||||
// accepted both exclusive creates. A retry of the same create may repeat it;
|
||||
// another layout identity may not mark this record ready.
|
||||
|
||||
@@ -567,6 +567,7 @@ stateDiagram-v2
|
||||
| From | To | Guard | Enforced in | Protects |
|
||||
|---|---|---|---|---|
|
||||
| no lifecycle record | named volume with immutable layout id | master lifecycle create mints the id once; a lost directory-sync reply settles the same record on retry. Lookup resolves the durable name/id without creating one; workload launch carries both and selects a local directory keyed by id | `core/lifecycle/store.go` `CreateVolume`; master `CreateVolume`, `GetVolume`; `core/rpc/lifecycleclient` `ResolveVolume`; launcher `blockVolumeArgs`; blockvolume `parseFlags` | `INV-SNAPK-VOLUME-DIR-001` |
|
||||
| pending ordinary create with a proved id8 collision | pending create with a fresh durable layout id | rejected exclusive VOLUME create, valid foreign full identity belongs to the selected name/id8 directory; not ready, not attached, not a restore; persist replacement before retry, settle unknown rename on replay; never modify the colliding volume | `LayoutStore.CreateVolumeRecord`; `FileStore.RedrawPendingLayoutID`; master `createLifecycleVolume` | `INV-CREATE-DIR-COLLISION-001` |
|
||||
| idle | snap(s) | caller is the holder at HEAD's epoch (epoch, server and claim id); HEAD present; snap(s) again is a replay, any other activity is refused | head.go `Head.Begin`, `runTransition` | `INV-SNAPK-HEAD-WRITE-001`, `INV-SNAPK-BEGIN-001` |
|
||||
| snap(s) | idle | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); over idle it succeeds without a write and means only that no activity remains; before resuming a failed stop, abort its still-open session and re-read HEAD: only matching live/idle resumes, detached goes Down, absent/unknown stays stopped | head.go `Head.Abort`; durable/provider_layout.go `settleLayoutStop` | `INV-SNAPK-ABORT-001` |
|
||||
| snap(s) | idle, current = root | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); the previous manifest builds to HEAD's current root; the new own chunks, every segment and the root are present; a new snapshot name records bounded retention facts once, while replay preserves them | commit.go `Head.Commit`, `RunCommit` | `INV-SNAPK-COMMIT-REACH-001`, `INV-SNAPK-TXN-INTERRUPT-001`, `INV-SNAPK-SNAPSHOT-META-001` |
|
||||
@@ -785,6 +786,9 @@ Notes:
|
||||
| `INV-AUTH-ONE-REPLICATED-FACTOR-001` | CreateVolume admits a replicated volume only if the master can decide it: its replication factor equals the master's one slot count (--expected-slots-per-volume) and the lifecycle product loop runs (only that loop binds, mints and promotes it). | M2 none → Bound (a created replicated volume's first line) | `core/host/master/services.go` `CreateVolume`; `core/host/master/host.go` `Config.LifecycleProductLoop`; `core/authority/controller.go` `ExpectedSlotsPerVolume`, `validateVolumeTopology` | `TestAnRF2CreateOnAnRF3MasterIsRefusedAndFailoverContinues`, `TestAReplicatedCreateWithTheProductLoopOffIsRefused` (`core/host/master/create_rf_mismatch_test.go`) | — (an admission check). Limits: single-replica volumes are admitted at any slot count (they never reach the check); a static --topology file with a mismatched volume is not checked at start (a cluster spec is: `INV-AUTH-REPLICATED-SPEC-NEEDS-LOOP-001`) | ACTIVE |
|
||||
| `INV-AUTH-REPLICATED-SPEC-NEEDS-LOOP-001` | blockmaster refuses to start when its cluster spec holds a replicated volume it could never decide: one whose replication factor differs from --expected-slots-per-volume, or any while the lifecycle product loop is off (only that loop binds, mints and promotes it). | M2 none → Bound (a replicated cluster-spec volume's first line) | `cmd/blockmaster/product_loop_guard.go` `requireProductLoop`; `cmd/blockmaster/main.go` `run` | `TestReplicatedClusterSpecWithTheProductLoopOffIsRefused`, `TestTheProductLoopGuardPassesWhatItShould`, `TestAClusterSpecVolumeOfAnotherReplicationFactorIsRefused`, `TestAPlacementOnlyClusterSpecVolumeIsChecked` (`cmd/blockmaster/product_loop_guard_test.go`) | — (a startup configuration check). Limits: static `--topology` is not refused (its observation controller mints), and has no automatic failover in v1 | ACTIVE |
|
||||
| `INV-CREATE-ONE-IDENTITY-001` | One name, one layout identity; no directory but the record's holds a live HEAD (not none, not deleted). A served volume's deleted name is never created again. | M2 none → created (CreateVolume, restore target creation) | `core/host/master/services.go` `CreateVolume`, `createLifecycleVolume`; `core/frontend/chunkstore/layout/start.go` `Start` | `TestARefusedRestoreLeavesNoTargetRecord` (`core/host/master/restore_refusal_test.go`), `TestARealCatalogRestoreOfARestoreTargetLeavesNothing`, `TestAServedThenDeletedNameIsStillRefused` (`core/host/master/restore_refusal_catalog_test.go`), `TestCreateVolume` (`core/frontend/chunkstore/layout/create_test.go`), `TestDecodeHead_RefusesAnotherVolumesHead` (`core/frontend/chunkstore/layout/head_test.go`) | VolumeCreate OneIdentity (its second clause: a directory with a live HEAD is the record's). Scope: only a refused restore's record, which never left the creation phase (never assigned, never served), is removed, with no filer write. Limits: a served volume's deleted name stays refused until 1.1 | ACTIVE |
|
||||
| `INV-CREATE-DIR-COLLISION-001` | Only a rejected exclusive VOLUME create proving a valid foreign full id in the selected name/id8 directory permits an unready, unattached ordinary create to redraw. Ready, attached and restore records refuse redraw. | M2 pending create collision → pending create with fresh id | `core/frontend/chunkstore/layout_create.go` `CreateVolumeRecord`; `core/lifecycle/store.go` `RedrawPendingLayoutID`; `core/host/master/services.go` `createLifecycleVolume` | `TestCreateVolumeExclusiveCollisionRedraws`, `TestCollisionExistingVolumeSafety`, `TestDirectoryCollisionIsOnlyAnExclusiveCreateRefusal`, `TestRedrawPendingLayoutID` | MasterCreate3 MUST-VIOLATE rows 220-224; no-proof redraw, use-before-persist and remint-on-replay mutants violate OneIdentity; no change to HEAD ownership/lease rules | ACTIVE |
|
||||
| `INV-CREATE-DIR-COLLISION-SETTLE-001` | A collision replacement is persisted before use. A lost synchronization reply settles the identity already on disk; a retry never remints it. | M2 pending create collision → pending create with fresh id | `core/frontend/chunkstore/layout_create.go` `CreateVolumeRecord`; `core/lifecycle/store.go` `RedrawPendingLayoutID`; `core/host/master/services.go` `createLifecycleVolume` | `TestCreateVolumeExclusiveCollisionRedraws`, `TestCollisionExistingVolumeSafety`, `TestDirectoryCollisionIsOnlyAnExclusiveCreateRefusal`, `TestRedrawPendingLayoutID` | MasterCreate3 MUST-VIOLATE rows 220-224; no-proof redraw, use-before-persist and remint-on-replay mutants violate OneIdentity; no change to HEAD ownership/lease rules | ACTIVE |
|
||||
| `INV-CREATE-DIR-COLLISION-FOREIGN-001` | A rejected exclusive create leaves the colliding volume metadata and payload byte-identical, with no new activity or lock; that volume remains attachable and serves its data. | M2 pending create collision → pending create with fresh id | `core/frontend/chunkstore/layout_create.go` `CreateVolumeRecord`; `core/lifecycle/store.go` `RedrawPendingLayoutID`; `core/host/master/services.go` `createLifecycleVolume` | `TestCreateVolumeExclusiveCollisionRedraws`, `TestCollisionExistingVolumeSafety`, `TestDirectoryCollisionIsOnlyAnExclusiveCreateRefusal`, `TestRedrawPendingLayoutID` | MasterCreate3 MUST-VIOLATE rows 220-224; no-proof redraw, use-before-persist and remint-on-replay mutants violate OneIdentity; no change to HEAD ownership/lease rules | ACTIVE |
|
||||
| `INV-CLI-TYPED-REFUSAL-001` | The chunk CLI reports a restore the master refused for a foreign source as `restore_source_not_own` (from the master's typed reason, never its text) and a volume the master does not know as `volume_not_found`. | M2 none → created (restore refusal); CLI volume resolve | `core/host/master/services.go` `CreateVolume`; `core/rpc/lifecycleclient/reason.go` `WithReason`, `Reason`; `cmd/sw-block/chunk_b.go` `chunkRestore`, `run` | `TestOpsChunkTypedRefusalCodes` (`cmd/sw-block/chunk_typed_codes_test.go`), `TestReasonRoundTrip` (`core/rpc/lifecycleclient/reason_test.go`), `TestARealCatalogRestoreOfARestoreTargetLeavesNothing` (`core/host/master/restore_refusal_catalog_test.go`) | — (reporting only; the refusal is `INV-CREATE-ONE-IDENTITY-001`'s). Limits: other FailedPrecondition refusals stay the generic `not_admitted` | ACTIVE |
|
||||
| `INV-CLI-RESTORE-VERB-001` | `volume restore --abort` changes nothing unless the master records this command's source, snapshot and request id for the target and this host's settings name exactly it (volume, master, `--layout-id` alone in the extra arguments); a re-run counts only this replica's published line as placed. | client (no state machine): the CLI side of M2 restore create, placement and delete | `cmd/sw-block/volume_backup.go` `volumeRestoreAbort`, `volumeRestore`, `restorePlaced`; `core/host/master/services.go` `lifecycleVolumeResponse` | `TestVolumeRestoreAbortRefusesAForeignTarget`, `TestVolumeRestoreAbortRefusesAnotherLocalInstallation`, `TestVolumeRestoreAbortInterruptedAtEveryStepCompletes`, `TestVolumeRestoreCrashTableBothWays`, `TestVolumeRestorePublicationDuringThePlacement`, `TestVolumeRestorePlacementOfAnotherLineRefuses`, `TestVolumeRestoreCreatesPlacesAndStarts`, `TestVolumeBackupTakesOneSnapshotAndRerunReplays`, `TestVolumeBackupRefusals`, `TestVolumeBackupIncompleteAnswerIsUnknown` (`cmd/sw-block/volume_backup_test.go`), `TestGetVolumeAnswersTheRecordedRestoreTuple` (`core/host/master/volume_restore_tuple_test.go`) | — (the command's model is checked outside the repository; its trace is on the pull request) | ACTIVE |
|
||||
| `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestLayoutGrantedEpochIssuerSites`, `TestLayoutEpochEnumerationRejectsANewIssuer`, `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`); also in `core/authority/layout_granted_epoch_guard_test.go` | `ControlPlane` `UniqueEpoch` | ACTIVE |
|
||||
@@ -1207,7 +1211,7 @@ Notes:
|
||||
| `INV-WS-DELETE-WITHOUT-ACK-001` | A delete without the holder's acknowledgement is admitted only while the master's record still awaits a replica store (stage 1), marked durably first; the mark freezes the wait, so the primary never serves. Past stage 1 the live-lease refusal stays. | M2 any authority line, stores still awaited → DeleteReserved without the holder's acknowledgement | `core/host/master/volume_delete_authority.go` `Reserve`; `core/host/master/store_attestation.go` `markDeleteWithoutAck`, `awaited` | `TestANeverCreatedVolumeIsDeletedWithoutItsHolder`, `TestAnEstablishedVolumeIsNotDeletedUnderALiveLease` (`core/host/master/workspace_delete_never_created_test.go`); `TestAStage2VolumeKeepsTheLiveLeaseRefusal`, `TestTheDeleteMarkFreezesTheStoreWait`, `TestAStage2VolumeIsNotMarkedForADeleteWithoutAck` (`core/host/master/workspace_delete_proof_test.go`); `TestDeleteMarkWriterCensus`, `TestDeleteMarkWriterCensusControls` (`core/host/master/store_attestation_census_test.go`) | CreateEvid2 model rows `mut_delete_on_flag_only`, `mut_no_horizon` | ACTIVE |
|
||||
| `INV-CLI-DELETE-PROGRESS-001` | Volume deletion bounds each sweep, continues across transient filer failures while objects are removed, and returns a retryable unavailable answer with progress after a no-progress window. | M9 deleting → deleted | `cmd/sw-block/chunk_volume_delete.go` `deleteVolumeWithProgress` | `TestVolumeDeleteContinuesAcrossTransientObjectFailures` | Existing ordered delete; no new persisted state. | ACTIVE |
|
||||
| `INV-SNAPK-DELETE-GUARD-001` | A source scan requires DeleteVolume to run no-holder check, deleting, release, object deletes and deleted in that order, and allows it as the only remover besides RemoveUnreachable. | M9 idle → deleting → deleted | `core/frontend/chunkstore/layout` (source scan of `delete.go`) | `TestGuard_WritersTransitionsAndRemovers`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-VOLUME-DIR-001` | A volume's master-minted layout identity is immutable; its directory is <name>-<first 8 hex of that id>, created exclusively and never reused. A foreign chunk's owning directory is checked against its full VOLUME id. | Content-named layout and lifecycle create/lookup/launch | `core/frontend/chunkstore/layout` `VolumeDir`; `core/lifecycle/store.go` `CreateVolume`; `core/host/master/services.go` `CreateVolume`, `GetVolume`; `core/rpc/lifecycleclient`; `core/launcher/k8s_renderer.go`; `cmd/blockvolume/main.go` `parseFlags`; `core/host/volume/chunk_control.go` `catalogVolume`, `ListSnapshots`, `DeleteSnapshot`, `Usage`; `cmd/blockvolume/chunk_remote.go` `chunkAttachCheck`; `core/frontend/chunkstore/layout/read.go` `Image.Chunk`; `core/rpc/lifecycleclient/identity.go` `ResolveVolume` | `TestRead_ForeignChunkFromSourcePool`, `TestRead_ForeignChunkNeedsTheOwnersVolumeID`; `TestLifecycleLayoutIdentity`, `TestLayoutIdentityWriterAndReaders`; `TestGetLifecycleVolumeResolvesOnlyTheDurableIdentity`; `TestResolveVolumeNeverInventsAnIdentity`; `TestLauncherCarriesTheMasterLayoutIdentity`; `TestBlockvolumeLayoutIdentitySelectsTheLocalRoot`; `TestChunkControlUsesTheBoundLayoutIdentity`, `TestChunkControlCatalogLookupErrorIsNotAbsence`, `TestChunkAttachCheckAppliesVolumeRules`; `TestHeadReaders_Enumeration`, `TestDeleteAndDirectorySites_Enumeration` | Lifecycle ids are durable record fields, not assignment epochs. Old records without the field are refused by the new-layout lookup; host metadata is bound to the full name/id and does not fall back to a previous incarnation. Data-path, scheduled snapshot and cleaning callers plus Linux crash qualification remain cutover work. | ACTIVE |
|
||||
| `INV-SNAPK-VOLUME-DIR-001` | A ready volume keeps its master-minted layout identity. Its <name>-<id8> directory is created exclusively and never reused. Foreign chunk owners are checked against their full VOLUME identity. | Content-named layout and lifecycle create/lookup/launch | `core/frontend/chunkstore/layout` `VolumeDir`; `core/lifecycle/store.go` `CreateVolume`; `core/host/master/services.go` `CreateVolume`, `GetVolume`; `core/rpc/lifecycleclient`; `core/launcher/k8s_renderer.go`; `cmd/blockvolume/main.go` `parseFlags`; `core/host/volume/chunk_control.go` `catalogVolume`, `ListSnapshots`, `DeleteSnapshot`, `Usage`; `cmd/blockvolume/chunk_remote.go` `chunkAttachCheck`; `core/frontend/chunkstore/layout/read.go` `Image.Chunk`; `core/rpc/lifecycleclient/identity.go` `ResolveVolume` | `TestRead_ForeignChunkFromSourcePool`, `TestRead_ForeignChunkNeedsTheOwnersVolumeID`; `TestLifecycleLayoutIdentity`, `TestLayoutIdentityWriterAndReaders`; `TestGetLifecycleVolumeResolvesOnlyTheDurableIdentity`; `TestResolveVolumeNeverInventsAnIdentity`; `TestLauncherCarriesTheMasterLayoutIdentity`; `TestBlockvolumeLayoutIdentitySelectsTheLocalRoot`; `TestChunkControlUsesTheBoundLayoutIdentity`, `TestChunkControlCatalogLookupErrorIsNotAbsence`, `TestChunkAttachCheckAppliesVolumeRules`; `TestHeadReaders_Enumeration`, `TestDeleteAndDirectorySites_Enumeration` | Lifecycle ids are durable record fields, not assignment epochs. Old records without the field are refused by the new-layout lookup; host metadata is bound to the full name/id and does not fall back to a previous incarnation. Data-path, scheduled snapshot and cleaning callers plus Linux crash qualification remain cutover work. | ACTIVE |
|
||||
| `INV-SNAPK-TOMBSTONE-001` | For a restore target without HEAD (never created, or a restore died between its two creates) the operator writes a deleted HEAD exclusively in its directory before releasing, so the restore cannot create it later. | M9 source HEAD, dependents | `core/frontend/chunkstore/layout` `delete.go` `OperatorReleaseDependent`, `TargetStore.CreateDeletedHead` | `TestOperatorReleaseDependent`, `TestOperatorReleaseDependent_TombstoneLosesToTheRestore`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-KEEP-HEAD-001` | Nothing removes a HEAD, a VOLUME or a volume directory: a volume delete removes only pool, segment and root objects; a source scan lists every delete and every directory-naming site in core/ and cmd/. | M9 deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`; (source scan) | `TestDeleteVolume_RemovesOnlyObjects`, `TestDeleteAndDirectorySites_Enumeration` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
| `INV-SNAPK-CREATE-001` | A new volume or restore target gets VOLUME then an unclaimed HEAD (epoch 0, no holder, no claim id, idle), each created exclusively; only createVolume and the operator's tombstone create a HEAD; the first Start claims it from a fresh root. | M9 absent → idle | `core/frontend/chunkstore/layout` `create.go` `CreateVolume`, `CreateTarget` | `TestCreateVolume`, `TestCreateVolume_InterruptAtEveryStep`, `TestUnclaimedHead_Shape`, `TestStart_ClaimsAnUnclaimedHeadFromAFreshRoot`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE |
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Volume directory collisions
|
||||
|
||||
A directory uses the volume name and the first eight hexadecimal digits of
|
||||
its full layout identity. Two different full identities can select the same
|
||||
directory. The exclusive VOLUME create refuses that collision without writing
|
||||
VOLUME, HEAD, objects or payloads in the existing volume.
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
pending --> pending: ordinary storage error; retry same identity
|
||||
pending --> replacementPending: exclusive create proves a valid foreign id8 collision
|
||||
replacementPending --> pending: persist fresh full identity, retry in fresh directory
|
||||
pending --> ready: matching VOLUME and HEAD created
|
||||
ready --> ready: identical create replay
|
||||
```
|
||||
|
||||
Only an ordinary, not-ready, unattached lifecycle record can redraw. A restore
|
||||
keeps its source/request binding and is not handled by this transition. A corrupt
|
||||
VOLUME, an unrelated identity mismatch, or an unknown store outcome never proves
|
||||
a collision. Ordinary reads and attach still reject every full-ID mismatch.
|
||||
|
||||
One RPC performs at most one redraw. It returns a retry response after recording
|
||||
the replacement; the next RPC creates the new directory. A replacement first
|
||||
lands through the lifecycle store's file-sync, rename and directory-sync path.
|
||||
If its synchronization result is unknown, a retry settles that on-disk identity
|
||||
before publishing it, rather than generating another. No ready identity changes.
|
||||
|
||||
The master serializes create and placement under workspaceMu. This is a change
|
||||
to pending creation only, not an assignment, lease, epoch or serving decision.
|
||||
MasterCreate3 checks the collision transition and OneIdentity (MUST-VIOLATE
|
||||
rows 220-224): redraw without proof, use before persistence and remint on
|
||||
replay each violate the invariant. Linux focused regression controls pass;
|
||||
the full master package's qualification remains open.
|
||||
Reference in new issue
Block a user