mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13c19663d9 | ||
|
|
911890f385 | ||
|
|
f4dcbbb227 | ||
|
|
46a3a7ee3b | ||
|
|
1e3ef67f07 | ||
|
|
20d2c3ebf5 | ||
|
|
c24e8b23ae | ||
|
|
6fb4dccca6 | ||
|
|
b6072afc8a | ||
|
|
e18dd62337 | ||
|
|
332a3dcdec | ||
|
|
c6e467bc71 | ||
|
|
bb8f757d73 | ||
|
|
f456af94e3 | ||
|
|
c24f81ee4e | ||
|
|
49b747b417 | ||
|
|
928bad3287 | ||
|
|
f994664614 | ||
|
|
960a914281 | ||
|
|
d6d06bf7bb |
No files matched your search
@@ -327,28 +327,12 @@ func (c *TopologyController) processSupportedVolumeLocked(
|
||||
c.outcome[vol.VolumeID] = "no ask: " + reason
|
||||
return
|
||||
}
|
||||
// Same-ask dedupe: while the identical ask is pending (queued, or
|
||||
// taken by the publisher and still being applied), do not
|
||||
// re-enqueue. Without this guard, repeated identical supported
|
||||
// feeds would mint a new Reassign epoch each iteration —
|
||||
// authority churn. An identical ask that is no longer pending
|
||||
// ended without a publication (lost): enqueue it again, keeping
|
||||
// its DesiredAt so a repeatedly lost ask still reports Stuck.
|
||||
// Same-ask dedupe: if the identical ask is already the current
|
||||
// desired, do not re-enqueue. Without this guard, repeated
|
||||
// identical supported feeds would mint a new Reassign epoch
|
||||
// each iteration — authority churn.
|
||||
if prev, ok := c.desired[vol.VolumeID]; ok && sameAsk(prev.Ask, ask) {
|
||||
since := prev.DesiredAt.UTC().Format(time.RFC3339Nano)
|
||||
if c.queue.pending(vol.VolumeID) {
|
||||
c.outcome[vol.VolumeID] = fmt.Sprintf("already desired since %s: %s %s (%s)", since, ask.Intent, ask.ReplicaID, prev.Reason)
|
||||
return
|
||||
}
|
||||
// Not pending also after the publisher published it since the line
|
||||
// was read: lost only while the line is still the one decided against.
|
||||
if line, ok := c.reader.VolumeAuthorityLine(vol.VolumeID); ok != hasLine || line != currentLine {
|
||||
c.outcome[vol.VolumeID] = fmt.Sprintf("no ask: the line moved to %s@%d while deciding against %s@%d", line.ReplicaID, line.Epoch, currentLine.ReplicaID, currentLine.Epoch)
|
||||
return
|
||||
}
|
||||
c.queue.enqueue(ask)
|
||||
c.outcome[vol.VolumeID] = fmt.Sprintf("enqueued again %s %s (%s): desired since %s, its last ask ended without a publication", ask.Intent, ask.ReplicaID, prev.Reason, since)
|
||||
applyProjectedMove(projectedLoad, vol, currentLine, hasLine, ask)
|
||||
c.outcome[vol.VolumeID] = fmt.Sprintf("already desired since %s: %s %s (%s)", prev.DesiredAt.UTC().Format(time.RFC3339Nano), ask.Intent, ask.ReplicaID, prev.Reason)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -566,14 +550,13 @@ func (c *TopologyController) decideVolume(
|
||||
return AssignmentAsk{}, "the current primary is acceptable; rebalance target " + target.ReplicaID + " has no planned-move evidence", false
|
||||
}
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: target.ReplicaID,
|
||||
DataAddr: target.DataAddr,
|
||||
CtrlAddr: target.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: plannedEvidence(target.PromotionEvidence),
|
||||
Incarnation: target.Incarnation,
|
||||
ExpectCurrent: expectedLineOf(currentLine),
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: target.ReplicaID,
|
||||
DataAddr: target.DataAddr,
|
||||
CtrlAddr: target.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: plannedEvidence(target.PromotionEvidence),
|
||||
Incarnation: target.Incarnation,
|
||||
}, "rebalance", true
|
||||
}
|
||||
return AssignmentAsk{}, "the current primary is acceptable", false
|
||||
@@ -600,14 +583,13 @@ func (c *TopologyController) decideVolume(
|
||||
// its target (one decider): no evidence, no promotion.
|
||||
if best.PromotionEvidence.Kind == adapter.PrimaryKindPromotion {
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: best.ReplicaID,
|
||||
DataAddr: best.DataAddr,
|
||||
CtrlAddr: best.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: best.PromotionEvidence,
|
||||
Incarnation: best.Incarnation,
|
||||
ExpectCurrent: expectedLineOf(currentLine),
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: best.ReplicaID,
|
||||
DataAddr: best.DataAddr,
|
||||
CtrlAddr: best.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: best.PromotionEvidence,
|
||||
Incarnation: best.Incarnation,
|
||||
}, "failover", true
|
||||
}
|
||||
why = "failover target " + best.ReplicaID + " has no promotion evidence"
|
||||
@@ -641,17 +623,10 @@ func refreshAsk(volumeID string, current ReplicaCandidate, line AuthorityBasis)
|
||||
CtrlAddr: current.CtrlAddr,
|
||||
Intent: IntentRefreshEndpoint,
|
||||
Incarnation: current.Incarnation,
|
||||
ExpectCurrent: expectedLineOf(line),
|
||||
ExpectCurrent: &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr},
|
||||
}
|
||||
}
|
||||
|
||||
// expectedLineOf conditions an ask on the line it was decided against: a
|
||||
// publication that lands while the ask waits in the queue (an operator's
|
||||
// failback) refuses it instead of being overwritten.
|
||||
func expectedLineOf(line AuthorityBasis) *ExpectedLine {
|
||||
return &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr}
|
||||
}
|
||||
|
||||
func volumeIncludesReplica(vol VolumeTopologySnapshot, replicaID string) bool {
|
||||
for _, slot := range vol.Slots {
|
||||
if slot.ReplicaID == replicaID {
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
package authority
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/adapter"
|
||||
)
|
||||
|
||||
// The same-ask dedupe holds a desired Reassign only while that ask is
|
||||
// pending: queued, or taken by the publisher and still being applied. An
|
||||
// ask the publisher took and ended without publishing (its apply refused
|
||||
// it) is lost, and the next intake of the same state enqueues it again.
|
||||
// Holding the lost ask as "already desired" would keep the volume on its
|
||||
// old primary for good.
|
||||
func TestALostReassignIsEnqueuedAgainOnTheNextIntake(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
reader := newFakeBasisReader()
|
||||
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
|
||||
reader.Set("v1", "r1", line)
|
||||
ctrl := NewTopologyController(TopologyControllerConfig{}, reader)
|
||||
r1 := candidate("r1", "s1", "d1", "c1", 10)
|
||||
r1.Reachable = false
|
||||
snap := ClusterSnapshot{
|
||||
CollectedRevision: 2,
|
||||
Servers: []ServerObservation{
|
||||
{ServerID: "s1", Reachable: true, Eligible: true},
|
||||
{ServerID: "s2", Reachable: true, Eligible: true},
|
||||
{ServerID: "s3", Reachable: true, Eligible: true},
|
||||
},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
|
||||
}
|
||||
submit := func() {
|
||||
t.Helper()
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
submit()
|
||||
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
|
||||
t.Fatalf("first intake: %+v, want Reassign r2", ask)
|
||||
}
|
||||
|
||||
// The publisher holds the ask (applying it): the same state again is
|
||||
// deduplicated, nothing is queued twice.
|
||||
submit()
|
||||
if out := ctrl.LastOutcome("v1"); !strings.HasPrefix(out, "already desired since ") {
|
||||
t.Fatalf("while the ask is being applied: outcome %q, want already desired", out)
|
||||
}
|
||||
|
||||
// The apply ended without a publication (the line is still r1@1) and
|
||||
// the publisher waits for its next ask: the ask is lost.
|
||||
next := make(chan AssignmentAsk, 1)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
go func() {
|
||||
if ask, err := ctrl.Next(ctx); err == nil {
|
||||
next <- ask
|
||||
}
|
||||
}()
|
||||
synctest.Wait() // the publisher is back in Next, holding nothing
|
||||
submit()
|
||||
select {
|
||||
case ask := <-next:
|
||||
if ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
|
||||
t.Fatalf("after the loss: %+v, want Reassign r2 again", ask)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
t.Fatalf("a lost Reassign was never enqueued again; the controller's outcome: %q", ctrl.LastOutcome("v1"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A Reassign lost again and again keeps its first DesiredAt across every
|
||||
// re-enqueue, so it still becomes Stuck once the retry window passes from
|
||||
// that first desire: a retry that re-anchored DesiredAt would never report
|
||||
// the volume stuck however long its asks keep failing.
|
||||
func TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck(t *testing.T) {
|
||||
const window = 10 * time.Second
|
||||
reader := newFakeBasisReader()
|
||||
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
|
||||
reader.Set("v1", "r1", line)
|
||||
ctrl := NewTopologyController(TopologyControllerConfig{RetryWindow: window}, reader)
|
||||
clk := newFakeClock(time.Date(2026, 12, 5, 9, 0, 0, 0, time.UTC))
|
||||
ctrl.SetNowForTest(clk.Now)
|
||||
r1 := candidate("r1", "s1", "d1", "c1", 10)
|
||||
r1.Reachable = false
|
||||
snap := ClusterSnapshot{
|
||||
CollectedRevision: 2,
|
||||
Servers: []ServerObservation{
|
||||
{ServerID: "s1", Reachable: true, Eligible: true},
|
||||
{ServerID: "s2", Reachable: true, Eligible: true},
|
||||
{ServerID: "s3", Reachable: true, Eligible: true},
|
||||
},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
|
||||
}
|
||||
first := clk.Now()
|
||||
ended, cancel := context.WithCancel(context.Background())
|
||||
cancel() // the publisher's next call after an apply that published nothing
|
||||
for cycle := 0; cycle < 4; cycle++ {
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cycle > 0 && !strings.HasPrefix(ctrl.LastOutcome("v1"), "enqueued again Reassign r2") {
|
||||
t.Fatalf("cycle %d: outcome %q, want the lost ask enqueued again", cycle, ctrl.LastOutcome("v1"))
|
||||
}
|
||||
if d, ok := ctrl.DesiredFor("v1"); !ok || !d.DesiredAt.Equal(first) {
|
||||
t.Fatalf("cycle %d at +%v: desired %+v (ok=%v), want DesiredAt kept at the first desire %v", cycle, clk.Now().Sub(first), d, ok, first)
|
||||
}
|
||||
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
|
||||
t.Fatalf("cycle %d: took %+v, want Reassign r2", cycle, ask)
|
||||
}
|
||||
_, _ = ctrl.Next(ended) // the apply ended without a publication: the ask is lost
|
||||
clk.Advance(4 * time.Second)
|
||||
}
|
||||
// +16 s since the first desire, past the 10 s window: the latest intake
|
||||
// (+12 s) found the desire unconfirmed past the window.
|
||||
ev, stuck := ctrl.LastConvergenceStuck("v1")
|
||||
if !stuck {
|
||||
t.Fatalf("a Reassign lost on every apply for %v is not reported stuck (window %v)", clk.Now().Sub(first), window)
|
||||
}
|
||||
if !ev.DesiredAt.Equal(first) || ev.Ask.ReplicaID != "r2" {
|
||||
t.Fatalf("stuck evidence %+v, want the first desire (%v) of Reassign r2", ev, first)
|
||||
}
|
||||
}
|
||||
|
||||
// publishOnRead runs publish once, right after the controller's skip+1-th
|
||||
// line read: the publisher applies its ask between the read an intake decides
|
||||
// against and that intake's dedupe.
|
||||
type publishOnRead struct {
|
||||
*fakeBasisReader
|
||||
skip int
|
||||
publish func()
|
||||
}
|
||||
|
||||
func (r *publishOnRead) VolumeAuthorityLine(volumeID string) (AuthorityBasis, bool) {
|
||||
line, ok := r.fakeBasisReader.VolumeAuthorityLine(volumeID)
|
||||
if r.publish != nil {
|
||||
if r.skip > 0 {
|
||||
r.skip--
|
||||
} else {
|
||||
p := r.publish
|
||||
r.publish = nil
|
||||
p()
|
||||
}
|
||||
}
|
||||
return line, ok
|
||||
}
|
||||
|
||||
// An ask the publisher publishes, and then asks past, while an intake is
|
||||
// deciding against the line read before that publication is not lost: the
|
||||
// intake must not enqueue it again, or a planned move would be minted twice.
|
||||
func TestAnAskPublishedDuringTheIntakeIsNotEnqueuedAgain(t *testing.T) {
|
||||
reader := newFakeBasisReader()
|
||||
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
|
||||
reader.Set("v1", "r1", line)
|
||||
publishing := &publishOnRead{fakeBasisReader: reader}
|
||||
ctrl := NewTopologyController(TopologyControllerConfig{}, publishing)
|
||||
r1 := candidate("r1", "s1", "d1", "c1", 10)
|
||||
r1.Reachable = false
|
||||
snap := ClusterSnapshot{
|
||||
CollectedRevision: 2,
|
||||
Servers: []ServerObservation{
|
||||
{ServerID: "s1", Reachable: true, Eligible: true},
|
||||
{ServerID: "s2", Reachable: true, Eligible: true},
|
||||
{ServerID: "s3", Reachable: true, Eligible: true},
|
||||
},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
|
||||
}
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
|
||||
t.Fatalf("first intake: %+v, want Reassign r2", ask)
|
||||
}
|
||||
ended, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
publishing.skip = 1 // the intake's load count reads the line first
|
||||
publishing.publish = func() {
|
||||
reader.Set("v1", "r2", AuthorityBasis{Assigned: true, ReplicaID: "r2", Epoch: 2, EndpointVersion: 1, DataAddr: "d2", CtrlAddr: "c2"})
|
||||
_, _ = ctrl.Next(ended) // published: the publisher is back for its next ask
|
||||
}
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out := ctrl.LastOutcome("v1"); strings.HasPrefix(out, "enqueued again") {
|
||||
t.Fatalf("an ask published during the intake was enqueued again: %q", out)
|
||||
}
|
||||
expectNoNext(t, ctrl)
|
||||
}
|
||||
|
||||
// A controller Reassign waits in the queue until the publisher takes it. A
|
||||
// publication that lands meanwhile outside the queue (an operator's failback)
|
||||
// is not overwritten by the ask decided against the older line, whether the
|
||||
// ask is a first one or a lost one enqueued again.
|
||||
func TestAQueuedReassignDoesNotOverwriteALaterPublication(t *testing.T) {
|
||||
for _, lost := range []bool{false, true} {
|
||||
holder := &basisReaderHolder{}
|
||||
ctrl := NewTopologyController(TopologyControllerConfig{}, holder)
|
||||
pub := NewPublisher(ctrl)
|
||||
holder.set(pub)
|
||||
if err := pub.apply(AssignmentAsk{VolumeID: "v1", ReplicaID: "r1", DataAddr: "d1", CtrlAddr: "c1", Intent: IntentBind}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
line, _ := pub.VolumeAuthorityLine("v1")
|
||||
r1 := candidate("r1", "s1", "d1", "c1", 10)
|
||||
r1.Reachable = false
|
||||
snap := ClusterSnapshot{
|
||||
CollectedRevision: 2,
|
||||
Servers: []ServerObservation{
|
||||
{ServerID: "s1", Reachable: true, Eligible: true},
|
||||
{ServerID: "s2", Reachable: true, Eligible: true},
|
||||
{ServerID: "s3", Reachable: true, Eligible: true},
|
||||
},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
|
||||
}
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if lost {
|
||||
nextAskOrFail(t, ctrl)
|
||||
ended, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
_, _ = ctrl.Next(ended) // the apply ended without a publication
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out := ctrl.LastOutcome("v1"); !strings.HasPrefix(out, "enqueued again Reassign r2") {
|
||||
t.Fatalf("outcome %q, want the lost ask enqueued again", out)
|
||||
}
|
||||
}
|
||||
if err := pub.apply(AssignmentAsk{VolumeID: "v1", ReplicaID: "r3", DataAddr: "d3", CtrlAddr: "c3", Intent: IntentReassign,
|
||||
Evidence: adapter.PrimaryEvidence{Kind: adapter.PrimaryKindPromotion, DurableLSN: 10, Basis: adapter.BasisPlanned},
|
||||
ExpectCurrent: &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch}}); err != nil {
|
||||
t.Fatalf("failback: %v", err)
|
||||
}
|
||||
ask := nextAskOrFail(t, ctrl)
|
||||
if ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
|
||||
t.Fatalf("lost=%v: took %+v, want Reassign r2", lost, ask)
|
||||
}
|
||||
if err := pub.apply(ask); !errors.Is(err, ErrExpectedLineMoved) {
|
||||
t.Fatalf("lost=%v: the queued Reassign decided against %s@%d: err=%v, want ErrExpectedLineMoved", lost, line.ReplicaID, line.Epoch, err)
|
||||
}
|
||||
if after, _ := pub.VolumeAuthorityLine("v1"); after.ReplicaID != "r3" || after.Epoch != line.Epoch+1 {
|
||||
t.Fatalf("lost=%v: line %+v, want the failback's r3@%d", lost, after, line.Epoch+1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,6 @@ type assignmentQueue struct {
|
||||
items map[string]AssignmentAsk
|
||||
order []string
|
||||
wake chan struct{}
|
||||
// taken is the volume of the ask the publisher took last and is still
|
||||
// applying: it is cleared when the publisher asks for its next one (the
|
||||
// publisher applies one ask at a time, between two calls of next).
|
||||
taken string
|
||||
}
|
||||
|
||||
func newAssignmentQueue() *assignmentQueue {
|
||||
@@ -46,19 +42,7 @@ func (q *assignmentQueue) discard(volumeID string) {
|
||||
delete(q.items, volumeID)
|
||||
}
|
||||
|
||||
// pending reports whether volumeID's ask is queued or still being applied.
|
||||
// A desired ask that is neither ended without a publication (lost).
|
||||
func (q *assignmentQueue) pending(volumeID string) bool {
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
_, queued := q.items[volumeID]
|
||||
return queued || q.taken == volumeID
|
||||
}
|
||||
|
||||
func (q *assignmentQueue) next(ctx context.Context) (AssignmentAsk, error) {
|
||||
q.mu.Lock()
|
||||
q.taken = "" // the publisher is done with the ask it took last
|
||||
q.mu.Unlock()
|
||||
for {
|
||||
q.mu.Lock()
|
||||
if len(q.order) > 0 {
|
||||
@@ -70,7 +54,6 @@ func (q *assignmentQueue) next(ctx context.Context) (AssignmentAsk, error) {
|
||||
continue
|
||||
}
|
||||
delete(q.items, vid)
|
||||
q.taken = vid
|
||||
q.mu.Unlock()
|
||||
return ask, nil
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/host/bootstrap"
|
||||
)
|
||||
|
||||
// A fenced replace decided by the gate reaches the controller as a failover
|
||||
// whatever the gate's reason. Here the gate replaces a primary only it reads
|
||||
// as unacceptable: its node reads format level 0 on a level-1 cluster (not
|
||||
// placement-eligible), while the primary's own slot flags still read
|
||||
// reachable and ready, and it still reports (no loss is recorded). The
|
||||
// controller judges acceptability by those flags alone, so unless the gate
|
||||
// marks the replaced primary unacceptable in what it submits, the controller
|
||||
// answers "the current primary is acceptable" on every tick and the fenced
|
||||
// decision never publishes.
|
||||
func TestAFencedReplaceOfAPrimaryOnlyTheGateRejectsReachesAReassign(t *testing.T) {
|
||||
ctrl, pub, _ := lossCluster(t, authority.TopologyControllerConfig{})
|
||||
h, buf := lossMaster(t, &fenceProbe{plain: lossPlain, fenced: lossFenced})
|
||||
h.ctrl = ctrl
|
||||
h.boot = &bootstrap.DurableAuthorityBootstrap{Publisher: pub}
|
||||
h.reads = newReadsLevels(time.Hour)
|
||||
h.reads.note("s1", "vol-rf3", "p-r1", 0) // the primary's node reads the old level
|
||||
h.reads.note("s2", "vol-rf3", "p-r2", 1)
|
||||
h.reads.note("s3", "vol-rf3", "p-r3", 1)
|
||||
h.format.v.Store(1)
|
||||
t0 := time.Date(2026, 12, 5, 8, 0, 0, 0, time.UTC)
|
||||
for tick := range 3 {
|
||||
now := t0.Add(time.Duration(tick) * time.Second)
|
||||
snap := silentPrimary() // r1's flags read reachable and ready
|
||||
snap.Volumes[0].Authority, _ = pub.VolumeAuthorityLine("vol-rf3")
|
||||
if snap.Volumes[0].Authority.Epoch != 1 {
|
||||
break // published
|
||||
}
|
||||
heard := map[string]time.Time{"r1": now, "r2": now, "r3": now} // r1 still reports: no loss
|
||||
h.notePrimaryLosses(rx(heard, now), &snap)
|
||||
h.takeGateReplaces()
|
||||
h.applyPromotionEvidenceGate(&snap)
|
||||
if l := gateLine(t, buf.String(), "vol-rf3"); !regexp.MustCompile(`primary_lost=false decision=replace\(fenced_at=2\)$`).MatchString(l) {
|
||||
t.Fatalf("tick %d: gate line %q; want a fenced replace with no loss recorded", tick, l)
|
||||
}
|
||||
outcomes, err := ctrl.SubmitObservedStateOutcomes(snap, authority.SupportabilityReport{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.reportReplaces("", nil, outcomes)
|
||||
}
|
||||
if strings.Contains(buf.String(), "controller: no ask: the current primary is acceptable") {
|
||||
t.Fatalf("the controller kept a primary the gate replaced:\n%s", buf.String())
|
||||
}
|
||||
if !regexp.MustCompile(`decision=replace\(fenced_at=2\) controller: enqueued Reassign r[23] \(failover\)`).MatchString(buf.String()) {
|
||||
t.Fatalf("the fenced replace was not enqueued as a failover:\n%s", buf.String())
|
||||
}
|
||||
waitLossLine(t, pub, "vol-rf3", func(l authority.AuthorityBasis) bool { return l.Epoch == 2 && l.ReplicaID != "r1" })
|
||||
}
|
||||
@@ -500,15 +500,12 @@ func (h *Host) applyPromotionEvidenceGate(snap *authority.ClusterSnapshot) (int,
|
||||
slot.PlannedMoveAllowed = false
|
||||
}
|
||||
}
|
||||
// A fenced replacement reaches the controller as a failover,
|
||||
// whatever the gate's reason (a recorded loss, or a primary only
|
||||
// the gate reads as unacceptable, such as one on a node below the
|
||||
// cluster's format level): its slot no longer reads acceptable, so
|
||||
// the controller publishes the fenced target with its fenced
|
||||
// evidence (the line is minted only at the fenced epoch), never
|
||||
// keeping the old line by its own acceptability predicate nor
|
||||
// A fenced replacement of a lost primary reaches the controller as
|
||||
// a failover: its slot no longer reads acceptable, so the controller
|
||||
// publishes the fenced target with its fenced evidence (the line is
|
||||
// minted only at the fenced epoch), never keeping the old line nor
|
||||
// routing the target as a planned rebalance without that epoch.
|
||||
if fencedReplace {
|
||||
if lost && fencedReplace {
|
||||
current := &vol.Slots[currentIdx]
|
||||
current.Reachable, current.ReadyForPrimary = false, false
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -105,15 +104,7 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) {
|
||||
return nil, fmt.Errorf("lifecycle: mkdir node inventory %q: %w", dir, err)
|
||||
}
|
||||
// INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability.
|
||||
// Every open syncs the full ancestor chain, also after a failed first open.
|
||||
for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) {
|
||||
if err := syncBindingParent(parent); err != nil {
|
||||
log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err)
|
||||
}
|
||||
if parent == filepath.Dir(parent) {
|
||||
break
|
||||
}
|
||||
}
|
||||
syncStoreAncestors(dir)
|
||||
|
||||
s := &NodeInventoryStore{
|
||||
dir: dir,
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -66,15 +65,7 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) {
|
||||
return nil, fmt.Errorf("lifecycle: mkdir placement intent %q: %w", dir, err)
|
||||
}
|
||||
// INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability.
|
||||
// Every open syncs the full ancestor chain, also after a failed first open.
|
||||
for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) {
|
||||
if err := syncBindingParent(parent); err != nil {
|
||||
log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err)
|
||||
}
|
||||
if parent == filepath.Dir(parent) {
|
||||
break
|
||||
}
|
||||
}
|
||||
syncStoreAncestors(dir)
|
||||
|
||||
s := &PlacementIntentStore{
|
||||
dir: dir,
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -120,15 +119,7 @@ func OpenFileStore(dir string) (*FileStore, error) {
|
||||
return nil, fmt.Errorf("lifecycle: mkdir %q: %w", dir, err)
|
||||
}
|
||||
// INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability.
|
||||
// Every open syncs the full ancestor chain, also after a failed first open.
|
||||
for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) {
|
||||
if err := syncBindingParent(parent); err != nil {
|
||||
log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err)
|
||||
}
|
||||
if parent == filepath.Dir(parent) {
|
||||
break
|
||||
}
|
||||
}
|
||||
syncStoreAncestors(dir)
|
||||
|
||||
s := &FileStore{
|
||||
dir: dir,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//go:build linux
|
||||
|
||||
package lifecycle
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
func directoryDevice(path string) (uint64, error) {
|
||||
var st unix.Stat_t
|
||||
if err := unix.Stat(path, &st); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(st.Dev), nil
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//go:build !linux
|
||||
|
||||
package lifecycle
|
||||
|
||||
import "errors"
|
||||
|
||||
func directoryDevice(string) (uint64, error) {
|
||||
return 0, errors.New("filesystem device comparison is unavailable on this platform")
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package lifecycle
|
||||
|
||||
import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Isolated subprocess tests replace device lookup without requiring mounts.
|
||||
var statDirectoryDevice = directoryDevice
|
||||
|
||||
// syncStoreAncestors protects every directory entry MkdirAll can create.
|
||||
// A mount point predates product startup: sync its filesystem root, but do not
|
||||
// cross into the installer's filesystem. Unknown devices keep the full walk.
|
||||
// The caller's separate records-directory recovery barrier remains mandatory.
|
||||
func syncStoreAncestors(dir string) {
|
||||
device, err := statDirectoryDevice(dir)
|
||||
checkBoundary := err == nil
|
||||
if err != nil {
|
||||
logDeviceFallback(dir, err)
|
||||
}
|
||||
for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) {
|
||||
if checkBoundary {
|
||||
parentDevice, err := statDirectoryDevice(parent)
|
||||
if err != nil {
|
||||
logDeviceFallback(parent, err)
|
||||
checkBoundary = false
|
||||
} else if parentDevice != device {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := syncBindingParent(parent); err != nil {
|
||||
log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err)
|
||||
}
|
||||
if parent == filepath.Dir(parent) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func logDeviceFallback(path string, err error) {
|
||||
log.Printf("lifecycle: could not determine filesystem device for %s (%v): syncing ancestors through the filesystem root", path, err)
|
||||
}
|
||||
@@ -15,11 +15,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// INV-LIFECYCLE-STORE-DURABLE-001: every open syncs the full ancestor chain,
|
||||
// including a retry after failed creation; a trailing separator changes no target.
|
||||
// INV-LIFECYCLE-STORE-DURABLE-001: every open syncs the same-device ancestors,
|
||||
// including the mount root; unknown devices retain the full ancestor walk.
|
||||
func TestLifecycleStoreParentSync(t *testing.T) {
|
||||
for _, kind := range []string{"node", "volume", "placement"} {
|
||||
for _, shape := range []string{"nested", "trailing-slash", "failed-parent-sync", "ancestor-permission", "relative-path"} {
|
||||
for _, shape := range []string{"nested", "trailing-slash", "failed-parent-sync", "ancestor-permission", "relative-path", "mount-boundary", "store-is-mount-root", "stat-store-failure", "stat-ancestor-failure", "stat-later-failure"} {
|
||||
t.Run(kind+"/"+shape, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@@ -40,6 +40,17 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) {
|
||||
}
|
||||
shape := os.Getenv("LIFECYCLE_PARENT_SHAPE")
|
||||
dir := filepath.Join(root, "new-parent", "deeper", "store")
|
||||
mountRoot := filepath.Join(root, "new-parent")
|
||||
if shape == "store-is-mount-root" {
|
||||
dir = filepath.Join(root, "mounted-store")
|
||||
mountRoot = dir
|
||||
}
|
||||
if shape == "mount-boundary" || shape == "store-is-mount-root" {
|
||||
// The installer/runtime creates the mount point before product startup.
|
||||
if err := os.MkdirAll(mountRoot, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if shape == "trailing-slash" {
|
||||
dir = filepath.Join(root, "store") + string(os.PathSeparator)
|
||||
}
|
||||
@@ -61,7 +72,40 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) {
|
||||
}
|
||||
want = append(want, "/")
|
||||
ancestor := want[len(want)-2]
|
||||
if shape == "mount-boundary" {
|
||||
want = []string{filepath.Dir(abs), mountRoot}
|
||||
} else if shape == "store-is-mount-root" {
|
||||
want = nil
|
||||
}
|
||||
want = append(want, abs)
|
||||
// Independently remember every directory entry this Open must create.
|
||||
var createdParents []string
|
||||
for entry := abs; ; entry = filepath.Dir(entry) {
|
||||
if _, err := os.Stat(entry); err == nil {
|
||||
break
|
||||
} else if !os.IsNotExist(err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
createdParents = append(createdParents, filepath.Dir(entry))
|
||||
}
|
||||
statDirectoryDevice = func(path string) (uint64, error) {
|
||||
if (shape == "stat-store-failure" && path == abs) || (shape == "stat-ancestor-failure" && path == filepath.Dir(abs)) || (shape == "stat-later-failure" && path == mountRoot) {
|
||||
return 0, &os.PathError{Op: "stat", Path: path, Err: os.ErrPermission}
|
||||
}
|
||||
if shape == "mount-boundary" || shape == "store-is-mount-root" {
|
||||
if path == mountRoot || strings.HasPrefix(path, mountRoot+"/") {
|
||||
return 2, nil
|
||||
}
|
||||
return 1, nil
|
||||
}
|
||||
if strings.HasPrefix(shape, "stat-") {
|
||||
if path == abs || (shape == "stat-later-failure" && path == filepath.Dir(abs)) {
|
||||
return 2, nil
|
||||
}
|
||||
return 1, nil // a stat error must disable even this later boundary
|
||||
}
|
||||
return 1, nil // keep the original same-device-through-root controls
|
||||
}
|
||||
var calls []string
|
||||
var warnings bytes.Buffer
|
||||
log.SetOutput(&warnings)
|
||||
@@ -115,6 +159,18 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) {
|
||||
if !reflect.DeepEqual(calls, want) {
|
||||
t.Fatalf("parent syncs %v want %v", calls, want)
|
||||
}
|
||||
for _, parent := range createdParents {
|
||||
found := false
|
||||
for _, call := range calls {
|
||||
found = found || call == parent
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("created entry's parent %q was not synced: %v", parent, calls)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(shape, "stat-") && (!strings.Contains(warnings.String(), "could not determine filesystem device") || !strings.Contains(warnings.String(), "syncing ancestors through the filesystem root")) {
|
||||
t.Fatalf("missing stat-error fallback warning: %s", warnings.String())
|
||||
}
|
||||
if shape == "ancestor-permission" {
|
||||
if strings.Count(warnings.String(), "lifecycle: could not sync ") != 1 || !strings.Contains(warnings.String(), "permission denied") || !strings.Contains(warnings.String(), "the store directory entry may not survive a crash right after its creation") {
|
||||
t.Fatalf("missing permission warning: %s", warnings.String())
|
||||
|
||||
@@ -9,7 +9,7 @@ The design is described in three documents, and this one collects their machines
|
||||
**Conventions.** These are the same as in the design documents.
|
||||
|
||||
- Code references name a file and a function, not a line number. Test references name the test function and its file.
|
||||
- A TLA+ entry names a specification in [`docs/spec/`](../spec/README.md) and an invariant or property defined in it; an entry naming a model checked outside the repository says so. The models check designs at small scale and are mapped to the code by reading (see the [limits](../spec/README.md#limits)).
|
||||
- A TLA+ entry names a specification in [`docs/spec/`](../spec/README.md) and an invariant or property defined in it. The models check designs at small scale and are mapped to the code by reading (see the [limits](../spec/README.md#limits)).
|
||||
- Status:
|
||||
- `ACTIVE`: a Go test in this repository asserts the statement.
|
||||
- `STUB`: the code enforces the statement (by reading), but no test asserts it yet. A release note must not claim behaviour backed only by a `STUB` row.
|
||||
@@ -192,7 +192,7 @@ flowchart LR
|
||||
|---|---|---|---|---|
|
||||
| Unbound | Bound (epoch 1, endpoint version 1) | `IntentBind`; no slot of this volume holds a present line (checked per volume, also after a restart); to move to another slot use `IntentReassign` | `core/authority/authority.go` `applyWithWorkspaceMove`, `boundReplicaForVolume`; `core/authority/controller.go` `decideVolume` (binds only a volume with no line) | `INV-AUTH-ONE-PRIMARY-001`, `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` |
|
||||
| Bound | Bound (endpoint version + 1) | `IntentRefreshEndpoint`; same epoch; new addresses, or the same addresses for another primary process (the line's incarnation differs); a no-op when both are unchanged; refused (`ErrExpectedLineMoved`) when the ask names the line it was decided against and the volume's line is no longer that one (replica, epoch, addresses) | `core/authority/authority.go` `applyWithWorkspaceMove`; `core/authority/directive.go` `expectedLineMoved` | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`, `INV-AUTH-RESTART-REISSUE-001` |
|
||||
| Bound | Reassigned (per-volume maximum epoch + 1) | `IntentReassign`; some earlier publication exists; an enrolled workspace volume changes only through a guarded move; refused (`ErrExpectedLineMoved`) when the ask names the line it was decided against (the controller's rebalance and failover, an operator's failback) and the volume's line is no longer that one, compared by replica and epoch, and by addresses only when the ask names them (the controller's moves do; an operator's failback names replica and epoch only, so an endpoint move to other addresses does not refuse it): a queued controller move never overwrites a reassign or an endpoint move to other addresses that landed after its decision; a same-address endpoint reissue (new endpoint version or incarnation, same addresses) still matches, and the move's epoch bump fences it | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume`; `core/authority/directive.go` `expectedLineMoved`; `core/authority/controller.go` `decideVolume` | `INV-AUTH-EPOCH-MINT-001`, `INV-AUTH-ONE-PRIMARY-001` |
|
||||
| Bound | Reassigned (per-volume maximum epoch + 1) | `IntentReassign`; some earlier publication exists; an enrolled workspace volume changes only through a guarded move | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `INV-AUTH-EPOCH-MINT-001`, `INV-AUTH-ONE-PRIMARY-001` |
|
||||
| any | (store write first) | with an authority store configured, every transition is written to the store before memory changes or subscribers are notified; a failed write publishes nothing; a write whose outcome is unknown (the directory fsync after the rename failed) fail-stops blockmaster, so no caller is told it failed | `core/authority/authority.go` `applyWithWorkspaceMove` | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` |
|
||||
| any (workspace) | Uncertain | a failed workspace authority write, including a lease extension; later changes for that volume, and renewals that would issue a new or extended grant, are refused until restart (a Revoking lease still gets its bounded drain reply) | `core/authority/authority.go` `applyWithWorkspaceMove`; `core/authority/workspace.go` `persistWorkspaceLocked`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease` | `INV-AUTH-UNCERTAIN-001` |
|
||||
| Uncertain | Uncertain (move answer) | failed move replies classify uncertainty after local locks release, before any admission refusal; request-context cancellation/deadline remain typed; known successful replay is unchanged | `core/authority/workspace.go` `WorkspaceMoveOutcomeError`; `core/host/master/workspace_service.go` `MoveWorkspace` | `INV-AUTH-UNCERTAIN-001` |
|
||||
@@ -201,34 +201,6 @@ flowchart LR
|
||||
| any authority line, stores still awaited (stage 1) | DeleteReserved without the holder's acknowledgement | the master's record is marked first, durably and in the lock that ends the store wait; the mark freezes the record in stage 1 (the wait never ends after it, so the primary, whose assignment keeps awaiting the stores, never serves); the reservation then skips the live-lease refusal. Deleting HEAD waits out the lease as above. Past stage 1, also while the end of creation is unrecorded (the volume may be serving), the live-lease refusal stays | `core/host/master/volume_delete_authority.go` `Reserve`; `core/host/master/store_attestation.go` `markDeleteWithoutAck`, `awaited`; `core/authority/workspace_delete_reservation.go` `ReserveNeverCreatedWorkspaceDeletion` | `INV-WS-DELETE-WITHOUT-ACK-001` |
|
||||
| DeleteReserved, removed from the desired spec | Retired metadata (reservation permanent) | no live lease, then a fresh bounded HEAD read proves deleted or absent; unread/live/deleting keeps the records. Remove authority durably, then placement and bindings, then the volume record; a crash retries the remaining removals. A startup lease skip schedules one more pass after the latest observed barrier, also without the product loop; full passes log skips. The store and its resweep inputs are untouched | `core/host/master/spec_retirement.go` `ReconcileDeletedSpecVolumes`, `startPostFloorRetirement`; `core/authority/workspace_retirement.go` `RetireDeletedWorkspace` | `INV-SPEC-DELETE-RETIRE-001`, `INV-SPEC-DELETE-RETRY-001` |
|
||||
|
||||
**Controller ask, per volume (between the promotion gate and the publisher).**
|
||||
|
||||
The topology controller turns a supported snapshot into at most one ask per volume. The publisher drains the controller's queue one ask at a time (its `Run` loop, between two calls of `next`). A fenced replace decided by the supported gate is submitted with the replaced primary's slot unacceptable, whatever the gate's reason, so the controller's own acceptability predicate never keeps that primary. An ask is pending while it is queued or held by the publisher; an identical ask is deduplicated only while it is pending.
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> Queued: intake decides an ask (desired, DesiredAt set)
|
||||
Queued --> Held: publisher takes it (next)
|
||||
Held --> Published: apply publishes (line moves)
|
||||
Held --> Lost: apply ends without a publication (publisher calls next again)
|
||||
Lost --> Queued: next intake decides the identical ask (DesiredAt kept)
|
||||
Queued --> Queued: identical ask decided (already desired)
|
||||
Held --> Held: identical ask decided (already desired)
|
||||
Published --> [*]: snapshot observes the new line (desired confirmed)
|
||||
```
|
||||
|
||||
| From | To | Event and guard | Enforced in | Protects |
|
||||
|---|---|---|---|---|
|
||||
| no desired ask | Queued | an intake of a supported snapshot decides an ask; the desired entry records DesiredAt. A fenced replace (with or without a recorded loss) reaches the controller with the replaced primary's slot unreachable and not ready, so its intake decides the failover to the fenced target | `core/authority/controller.go` `processSupportedVolumeLocked`, `decideVolume`; `core/host/master/product_loop.go` `applyPromotionEvidenceGate` | `INV-PROMOTE-REPLACE-HANDOFF-001`, `INV-PROMOTE-REPLACE-HANDOFF-002` |
|
||||
| Queued | Held | the publisher takes the ask; the queue records the volume it holds | `core/authority/queue.go` `next` | `INV-AUTH-DESIRED-RETRY-001` |
|
||||
| Queued or Held | (no change) | an intake decides the identical ask while it is pending: deduplicated (`already desired since T`), nothing queued twice | `core/authority/controller.go` `processSupportedVolumeLocked`; `core/authority/queue.go` `pending` | `INV-AUTH-DESIRED-RETRY-001` |
|
||||
| Held | Published | the apply publishes the line (epoch minted by the publisher) | `core/authority/authority.go` `applyWithWorkspaceMove` | `INV-AUTH-EPOCH-MINT-001` |
|
||||
| Held | Lost | the apply ends without a publication (refused, or dropped); the publisher asks for its next ask, which clears the held volume | `core/authority/queue.go` `next` | `INV-AUTH-DESIRED-RETRY-001` |
|
||||
| Lost | Queued (DesiredAt kept) | an intake decides the identical ask while the line, re-read after the pending check, is still the one it decided against (an ask published during the intake is not lost): enqueued again (`enqueued again ...`), the desired entry and its DesiredAt unchanged | `core/authority/controller.go` `processSupportedVolumeLocked` | `INV-AUTH-DESIRED-RETRY-001`, `INV-AUTH-DESIRED-RETRY-002` |
|
||||
| any desired (unconfirmed) | Stuck evidence | DesiredAt + retry window passed without the line observed; a repeatedly lost ask reaches it from its first desire | `core/authority/convergence.go` `evaluateStuckLocked` | `INV-AUTH-DESIRED-RETRY-002` |
|
||||
|
||||
Model: PromoLive r6, checked outside the repository (it is not in `docs/spec/`), models this handoff with the intake split as the code does it (read the line and decide; after the publisher may have run, enqueue only if the ask is not pending and the line is still the one read). `RoundProgress` and `QueuedMatchesLine` hold; the mutants `dedupe_keeps_lost`, `predicate_split` and `nonatomic_submit` are each caught. The retry window and the Stuck evidence are not modelled; their test is the evidence.
|
||||
|
||||
**Volume creation phase, in blockmaster's store record** (`core/host/master/store_attestation.go`, decided by `inCreationPhase` in `core/host/master/product_loop.go`). Every replacement entry (both promotion gates, the operator's failover and planned move, the rebalance) acts only on Established.
|
||||
|
||||
```mermaid
|
||||
@@ -1038,8 +1010,6 @@ Notes:
|
||||
| `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 |
|
||||
| `INV-AUTH-DESIRED-RETRY-001` | The controller deduplicates a desired ask only while it is pending: queued, or taken by the publisher and still being applied. An identical ask that ended without a publication, the line still the one it was decided against, is enqueued again on the next intake. | M2 controller ask: Queued or Held (deduplicated); Held → Lost; Lost → Queued | `core/authority/controller.go` `processSupportedVolumeLocked`; `core/authority/queue.go` `pending`, `next` | `TestALostReassignIsEnqueuedAgainOnTheNextIntake`, `TestAnAskPublishedDuringTheIntakeIsNotEnqueuedAgain` (`core/authority/controller_lost_ask_test.go`) | PromoLive r6 (outside the repository) `QueuedMatchesLine`, `RoundProgress` (mutants `dedupe_keeps_lost`, `nonatomic_submit`) | ACTIVE |
|
||||
| `INV-AUTH-DESIRED-RETRY-002` | An ask enqueued again keeps its first DesiredAt, so an ask lost on every apply still becomes Stuck once the retry window passes from that first desire. | M2 controller ask: Lost → Queued (DesiredAt kept); Stuck evidence | `core/authority/controller.go` `processSupportedVolumeLocked`; `core/authority/convergence.go` `evaluateStuckLocked` | `TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck` (`core/authority/controller_lost_ask_test.go`) | PromoLive r6 (outside the repository) `RoundProgress` (the retry; the retry window and Stuck are not modelled: the test is the evidence) | ACTIVE |
|
||||
| `INV-AUTH-RESTART-REISSUE-001` | A line records the primary process it was issued for (durable); a current primary reporting another process is re-issued its line at a new endpoint version, and a primary adopts no line issued for another process, so a restarted process never reuses the dead one's sessions. | M2 authority (RefreshEndpoint); M3 primary adoption | `core/authority/authority.go` `applyWithWorkspaceMove` (records the ask's or the source's incarnation); `core/authority/controller.go` `endpointStale`, `sameAsk`, `refreshAsk` (conditional on the line it read); `core/host/master/product_loop.go` `RunLifecycleProductTick`, `restartedHolderRefresh` (the product loop's direct path for a workspace-bound RF1 volume, conditional on the line it read); `core/authority/workspace.go` `persistWorkspaceTimedLocked`; `core/authority/observation_store.go` `SlotFactAt`; `core/host/master/host.go` (the source); `core/host/volume/host.go` `applyFact` | `TestPublisher_RestartedPrimaryGetsANewEndpointVersion`, `TestPublisher_AskWithoutAProcessIsIssuedForTheReportedOne`, `TestTopologyController_RestartedPrimaryAtTheSameAddressIsReissued`, `TestTopologyController_QueuedRefreshIsReplacedForANewerProcess`, `TestTopologyController_UnnamedLineIsReissuedOnceForTheReportingProcess`, `TestWorkspaceLeaseWriteKeepsTheLinesIncarnationAcrossReload`, `TestObservationStore_SlotFactAtIsTheProcessAtThoseEndpoints` (`core/authority/restart_endpoint_version_test.go`); `TestLinesNameTheirPrimarysProcess`, `TestLineForTheTargetsEndpointsNamesTheTargetsProcess` (`core/host/master/line_incarnation_test.go`); `TestRF1RuntimeVolumeIsReissuedToARestartedHolder`, `TestRF1RuntimeLineNamingNoProcessIsReissued`, `TestRF1RefreshDecidedBeforeACrossHostMoveIsNotApplied` (`core/host/master/rf1_restart_reissue_test.go`); `TestRefreshIsConditionalOnTheLineItWasDecidedAgainst`, `TestControllerRefreshNamesTheLineItWasDecidedAgainst` (`core/authority/refresh_expected_line_test.go`); `TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted`, `TestHost_ApplyFact_UnnamedLineIsNotAdoptedWhereLinesNameTheirProcess` (`core/host/volume/line_incarnation_test.go`); `TestHostConfigAdoptsOnlyLinesNamingThisProcess` (`cmd/blockvolume/lines_name_their_process_test.go`); `TestRestartedPrimaryAtTheSameEpochIsAdmitted` (`core/replication/primary_restart_session_test.go`) | — | ACTIVE |
|
||||
| `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, a failed write does not publish it, and an unknown outcome (directory fsync after the rename failed) fail-stops blockmaster: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove`; `core/authority/authority_store_file.go` `Put` (`failStopDurabilityUnknown` after a failed directory open or fsync behind the rename, every record; a close error after a good fsync is reported written; Windows keeps its previous behaviour) | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`); `TestPutFailStopsWhenTheDirectoryFsyncFailsAfterRename`, `TestPutReportsWrittenWhenOnlyTheDirectoryCloseFails` (`core/authority/authority_store_dir_fsync_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE |
|
||||
| `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE |
|
||||
@@ -1066,6 +1036,8 @@ Notes:
|
||||
|
||||
Notes:
|
||||
|
||||
- `INV-LIFECYCLE-STORE-DURABLE-001` directory coverage: volume, node and placement Open share `core/lifecycle/store_parent_sync.go` `syncStoreAncestors`. It syncs same-device ancestors through the mount root; an unknown device retains the full walk. The mandatory records-directory recovery barrier is unchanged. The mount point is installed externally: run `sync` after creating and mounting the state filesystem. See [the durability argument and installation residual](lifecycle-directory-sync.md).
|
||||
|
||||
- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: Store-directory ancestor sync on Open is best-effort: failures are logged and do not block startup; a new directory entry may not survive an immediate crash when an ancestor cannot be synced. Record-file and store-directory sync after a put remain mandatory. `NodeInventoryStore.RemoveNode`, `PlacementIntentStore.DeletePlacement` and `FileStore.DeleteVolume` do not fsync their directory after deletion, so a removed node, placement or volume record can reappear after a crash. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record.
|
||||
- `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`: a failure before the rename leaves the old record and is reported failed (the in-memory rollback test); a directory open or fsync failure after the rename leaves the outcome unknown and fail-stops the process, for every record type, so the restart reloads whatever survived and callers re-read. A workspace volume's uncertainty latch (`INV-AUTH-UNCERTAIN-001`) stays for its other causes.
|
||||
- `INV-AUTH-UNCERTAIN-001`: The cited test asserts the refusal after an unknown-outcome lease extension (rename landed, then a failure; the file store fail-stops on a directory fsync failure instead, `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`): the next renewal, a revocation and an endpoint change are all refused. The TLA+ configuration `S5_red_noUncertain` violates `UniqueEpoch` without it. A Revoking lease still gets its bounded drain reply, min(horizon, deadline), never extended: see M2 any (workspace) → Uncertain. A failed move on an uncertain volume is answered as an unknown outcome before any admission refusal, the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see M2 Uncertain → Uncertain (move answer). The renewal path reads uncertainty from the lease view (`INV-LEASE-VIEW-001`), not from `persistWorkspaceLocked`.
|
||||
@@ -1412,8 +1384,6 @@ Notes:
|
||||
| `INV-PROMOTE-ACK-PROFILE-MATCH-001` | The automatic path holds a lost primary's volume, before any fencing round and showing `ack_profile_mismatch`, when a probe answer names no ack profile or another than blockmaster's `--launcher-replication-ack`; blockmaster refuses to start with an unknown one. | M3 Supporting → promotion candidate (both gates) | `core/host/master/probe_round.go` `profileMismatch`; `core/host/master/product_loop.go` `automaticFailoverHold` (plain round), `fencedDecision` (fencing round); `core/host/volume/probe_round.go` `probeAnswer`; `cmd/blockvolume/main.go` `hostConfig`; `cmd/blockmaster/main.go` `parseFlags` | `TestTheAutomaticPathHoldsOnAnAckProfileMismatch`, `TestProbeRound_ReportsAnAckProfileMismatch`, `TestTheFencingRoundsAckProfileIsCheckedToo` (`core/host/master/ack_profile_mismatch_test.go`); `TestProbeAnswerNamesTheVolumesAckProfile` (`core/host/volume/probe_ack_profile_test.go`); `TestHostConfigAnswersTheVolumesOwnAckProfile` (`cmd/blockvolume/probe_ack_profile_test.go`); `TestBlockmasterRefusesAnUnknownLauncherReplicationAck` (`cmd/blockmaster/launcher_replication_ack_flag_test.go`) | — | ACTIVE |
|
||||
| `INV-PROMOTE-DECISION-REPORTED-001` | Every replace decision of the supported promotion gate is logged once after its tick: with the controller's outcome from the same submission (read under its lock, so a later intake cannot change it), as not submitted and why, or as a failed submit. Diagnostics only: no decision changes. | M3 Supporting → promotion candidate (supported gate → controller → publisher) | `core/host/master/product_loop.go` `submitPlacementSnapshots`, `noteGateReplace`, `reportReplaces`; `core/authority/controller.go` `SubmitObservedStateOutcomes`, `LastOutcome` | `TestAReplaceDecisionLogsWhatTheControllerDidWithIt` (cases: enqueued, already desired, no ask with why, not submitted, an intake after the submission does not change its report, a submission that did not carry the volume, one report per decision), `TestAProductTickReplaceLogsTheControllerOutcomeAndThePublication`, `TestABindingReadFailureAfterTheProbeReportsTheDecisionNotSubmitted` (`core/host/master/gate_controller_outcome_test.go`, `core/host/master/gate_binding_read_failure_test.go`) | — (diagnostics; no published specification models the log) | ACTIVE |
|
||||
| `INV-AUTHORITY-PUBLICATION-LOGGED-001` | Every authority publication is logged on the master's log with its volume, replica, epoch, endpoint version and intent, also when no event sink is set. Diagnostics only: no decision changes. | M3 controller → publisher (publication observer) | `core/host/master/product_loop.go` `recordAuthorityPublishedEvent` | `TestAPublicationIsLogged`, `TestAProductTickReplaceLogsTheControllerOutcomeAndThePublication` (`core/host/master/gate_controller_outcome_test.go`) | — (diagnostics; no published specification models the log) | ACTIVE |
|
||||
| `INV-PROMOTE-REPLACE-HANDOFF-001` | A fenced replace decided by the supported promotion gate, whatever its reason (a recorded loss, or a primary only the gate reads as unacceptable, such as one on a node below the cluster's format level), submits the replaced primary's slot as unreachable and not ready. | M2 controller ask: no desired ask → Queued (failover) | `core/host/master/product_loop.go` `applyPromotionEvidenceGate` | `TestAFencedReplaceOfAPrimaryOnlyTheGateRejectsReachesAReassign` (`core/host/master/gate_controller_replace_test.go`) | PromoLive r6 (outside the repository) `RoundProgress` (mutant `predicate_split`) | ACTIVE |
|
||||
| `INV-PROMOTE-REPLACE-HANDOFF-002` | The controller never keeps a primary the gate replaced by its own acceptability predicate: it publishes the fenced target with its fenced evidence, the line minted only at the fenced epoch. | M2 controller ask: no desired ask → Queued (failover); M3 Primary → another replica Primary at e+1 | `core/authority/controller.go` `decideVolume` | `TestAFencedReplaceOfAPrimaryOnlyTheGateRejectsReachesAReassign` (`core/host/master/gate_controller_replace_test.go`); `TestALostPrimarysFencedReplacementIsPublished` (`core/host/master/primary_loss_publish_test.go`) | PromoLive r6 (outside the repository) `RoundProgress` (mutant `predicate_split`) | ACTIVE |
|
||||
| `INV-PRIMARY-ACK-PROFILE-001` | A primary of a replicated line serves only when its own `--replication-ack` is the profile its assignment names (blockmaster's); otherwise its frontend is not Healthy and status names both profiles. So a lost primary, which does not answer, acknowledged under the master's profile. | M1 Primary → Serving (replicated line) | `core/host/master/services.go` `assignmentFact` (`ack_profile`); `core/host/volume/workspace_startup.go` `noteAckProfile`; `core/host/volume/projection_bridge.go` `projectionWithSupersede`; `core/host/volume/status_server.go` | `TestPrimaryOfAReplicatedLineServesOnlyUnderTheMastersAckProfile` (`core/host/volume/ack_profile_refusal_test.go`); `TestAssignmentNamesTheMastersAckProfile` (`core/host/master/ack_profile_mismatch_test.go`) | — | ACTIVE |
|
||||
| `INV-CSI-CONSUMES-AUTHORITY-001` | CSI never imports authority code or builds assignment facts; it takes the publish target from blockmaster and refreshes it before a stage, and blockmaster mints the IDs of the events CSI reports. | M2 (read side) | `core/csi/master_backend.go` `LookupPublishTarget`; `core/csi/node.go` `refreshPublishContext`; `core/host/master/observation_service.go` `ReportClusterEvent` | `TestG15a_CSI_DoesNotImportAuthorityOrConstructAssignmentFacts` (`core/csi/boundary_guard_test.go`); `TestG15e_CSIReattachUsesFreshPublishTargetAfterUnstage` (`core/csi/node_test.go`); `TestObservationService_ReportClusterEventAppearsInVolumeTimeline` (`core/host/master/observation_service_test.go`) | — | ACTIVE |
|
||||
| `INV-K8S-NONLOOPBACK-001` | Generated multi-node Helm values enable external iSCSI, external status and loopback rejection; with rejection enabled CSI never publishes a loopback target and fails closed when only loopback targets exist. | M2 (read side) | `cmd/sw-block/main.go` `runOpsGenerateHelmValues`; `core/csi/master_backend.go` `rejectFrontendAddr` | `TestOpsGenerateHelmValuesMultiNodeExternalISCSI` (`cmd/sw-block/main_test.go`); `TestNodeLoss_ControlStatusLookup_RejectsLoopbackPublishTargetsWhenEnabled`, `TestNodeLoss_ControlStatusLookup_FailClosedWhenOnlyLoopbackTargets` (`core/csi/master_backend_test.go`) | — | ACTIVE |
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Lifecycle directory recovery at a filesystem boundary
|
||||
|
||||
Opening a volume, node or placement store first creates missing directories.
|
||||
Each newly created directory entry needs its parent directory synced. The shared
|
||||
`syncStoreAncestors` helper syncs ancestors on the store's filesystem, including
|
||||
its mount root, and stops before the first ancestor with another device id.
|
||||
The separate records-directory recovery barrier remains mandatory before any
|
||||
loaded records are published or equality shortcuts become available.
|
||||
|
||||
The product does not mount filesystems or create their mount points. A mount
|
||||
point already exists when `MkdirAll` runs, so every directory it creates is below
|
||||
that point and every created entry has its parent within the synced range.
|
||||
When the store directory is itself the mount root, the ancestor walk syncs no
|
||||
parent on another filesystem; its own recovery barrier still syncs the store.
|
||||
Same-device paths continue through the filesystem root, including bind mounts.
|
||||
|
||||
A device lookup failure logs the failure and disables boundary detection for
|
||||
the rest of that walk. The helper then syncs through the root as before. Linux
|
||||
uses `stat` device ids; other platforms retain the full walk. Ancestor sync
|
||||
failures keep their existing warning contract. No record-write barrier, import
|
||||
syncfs selection, authority rule or persistent format changes.
|
||||
|
||||
One installation risk remains: a machine crash can lose a newly created mount
|
||||
point's entry on its parent filesystem if that filesystem has not committed it.
|
||||
The stored data remains on the unmounted filesystem. Run `sync` after creating
|
||||
and mounting the state filesystem, before starting blockmaster. A state path
|
||||
that is required to be mounted must not silently fall back to an empty directory
|
||||
on the parent filesystem.
|
||||
|
||||
The optimization avoids syncing unrelated ancestor filesystems. It does not
|
||||
bound waits inside the state filesystem or its records-directory recovery
|
||||
barrier. The walk adds device lookups proportional to path depth; no startup
|
||||
latency improvement is claimed without measurement.
|
||||
|
||||
`TestLifecycleStoreParentSync` covers each constructor, the same-device walk,
|
||||
mount boundary, store-as-mount-root, device lookup failures and independent
|
||||
coverage of every directory entry created by Open. It also retains ancestor
|
||||
sync failures, relative paths, trailing separators and reopen controls.
|
||||
@@ -117,21 +117,73 @@ systemd and root access.
|
||||
|
||||
## 1. Install the binaries and units
|
||||
|
||||
**Plan blockmaster's state storage before starting it.** Keep the holders' local data off both the state
|
||||
directory's filesystem and the filesystem holding its ancestors. In practice, put the holders' data on its own
|
||||
filesystem, not the root filesystem. With the shipped unit, the state directory is `/var/lib/sw-block-master`,
|
||||
including the authority and lifecycle stores. A different directory on the same filesystem is not enough. A
|
||||
dedicated state-directory mount alone does not isolate every startup sync: opening the store also syncs ancestor
|
||||
directories up to `/`, including `/var/lib` and `/var` with this layout. Keep write load low on those filesystems
|
||||
when restarting too. Under heavy writes, an `fsync` when blockmaster opens its state directory can wait for the
|
||||
**Plan blockmaster's state storage before starting it.** Keep the holders' local data off blockmaster's state
|
||||
filesystem. With the shipped unit, the state directory is `/var/lib/sw-block-master`, including the authority
|
||||
store and any lifecycle store. A different directory on the same filesystem is not enough.
|
||||
|
||||
In v1.1.2, with the state directory on its own filesystem, blockmaster's start no longer syncs any directory on the shared filesystem.
|
||||
Run `sync` after creating and mounting it. This commits the installer's mount-point entry on its parent
|
||||
filesystem. A failed device lookup logs a fallback to the full ancestor walk. See
|
||||
[directory recovery](design/lifecycle-directory-sync.md).
|
||||
|
||||
Under one buffered-write load, three starts per case measured shared-filesystem warm/cold medians of
|
||||
31.3/122.9 seconds, versus 1.6/2.5 seconds on a dedicated state filesystem; the dedicated warm maximum was
|
||||
13.2 seconds. The warm startup directory-fsync count fell from 30 to 15, with shared root-filesystem directory
|
||||
fsyncs falling from 30 to 0. These are measurements under that load, not a start-time promise.
|
||||
|
||||
**Do not mount an empty filesystem over existing blockmaster state.** It hides the existing stores
|
||||
beneath the mount, and starting blockmaster there can create a separate state history. For a new install,
|
||||
install the units (step 2 below), then create and mount the state filesystem and configure its persistent mount
|
||||
and the unit's mount dependency as migration step 5 shows, all before the first start in
|
||||
[section 2](#2-cluster-spec-and-blockmaster).
|
||||
Migrating existing state stops service: volumes fence once blockmaster's downtime outlasts their leases.
|
||||
To migrate an existing installation:
|
||||
|
||||
1. Stop and disable blockmaster with `sudo systemctl disable --now sw-blockmaster`, so a reboot does not start it,
|
||||
and keep it stopped throughout the migration. With v1.1.0 volume units on this host, stop those volumes first
|
||||
([section 4](#4-stop-a-volume)) and disable each with `sudo systemctl disable sw-blockvolume@<volume>`: their
|
||||
restart or their start at boot starts blockmaster again, and a v1.1.0 `volume stop` leaves the unit enabled.
|
||||
2. Mount the new filesystem at a temporary location. Copy the entire existing state directory onto it,
|
||||
preserving file contents, ownership, permissions and directory structure, including hidden files.
|
||||
3. Verify the copy against the stopped source, run `sync`, then unmount the temporary location. Retain the original state
|
||||
until the migration has been verified; do not initialize an empty replacement store.
|
||||
4. With the old state directory unmounted, move it aside to an unused backup path outside the mount point.
|
||||
If the old state directory is itself a mount point, unmount that filesystem and keep it intact as the backup,
|
||||
and remove its persistent mount configuration. The directory it uncovers is not the backup, but it can hold
|
||||
older files the mount hid: move it aside as well, to a separate path.
|
||||
Create an empty directory at the original state path. Do not leave the old stores under the mount: a missing
|
||||
mount at boot must not expose stale state as a usable fallback.
|
||||
5. Configure the new filesystem's persistent mount, for example in `/etc/fstab`. While blockmaster is still
|
||||
stopped, run `sudo systemctl edit sw-blockmaster` and add the following drop-in for the shipped state path:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
RequiresMountsFor=/var/lib/sw-block-master
|
||||
AssertPathIsMountPoint=/var/lib/sw-block-master
|
||||
```
|
||||
|
||||
If the state path differs, change both paths to the actual mount point. Run `sudo systemctl daemon-reload`.
|
||||
The dependency orders the service after its mount; the assertion refuses startup if the mount is absent,
|
||||
including if its configuration is lost. Keep these protections installed after the migration.
|
||||
6. Mount the copied filesystem at the configured state directory, verify that it contains the copied authority
|
||||
store, the lifecycle store if `--lifecycle-store` is set, and their permissions, and run `sync`.
|
||||
7. Enable and start blockmaster with `sudo systemctl enable --now sw-blockmaster` and verify that it opens the
|
||||
copied stores and reloads the existing records before considering the migration complete.
|
||||
If verification fails, stop it with `sudo systemctl disable --now sw-blockmaster`, keep it stopped, and correct
|
||||
the mount or copy before retrying.
|
||||
Once it verifies, start any volumes stopped in step 1 again with `volume start`, which enables their units.
|
||||
Remove the moved original, or the old state filesystem, only after this successful startup and state verification.
|
||||
|
||||
Under heavy writes on the state filesystem, an `fsync` when blockmaster opens its state directory can wait for the
|
||||
filesystem journal. In v1.1.2, startup also runs a `syncfs` for each store with changed import records on ext4, XFS,
|
||||
btrfs or tmpfs (Linux 5.8 or later), which waits for every pending write on that filesystem, including the holders'
|
||||
data. Starts took from about 20 seconds to over 150 seconds in our tests (one start was not ready after 2 minutes);
|
||||
this is not an upper bound. A volume whose lease expires stops serving until blockmaster is back; it is then
|
||||
granted again on the same holder, with its data. A forced move during that time can lose writes after the last
|
||||
published HEAD (see [forced move](volume-lifecycle.md#after-a-crash)).
|
||||
Restart blockmaster at low write load, including when the cluster spec has not changed. See the
|
||||
[restart known issue](releases/v1.1.1.md#known-issue-blockmaster-restart-can-stall-on-a-busy-filesystem).
|
||||
btrfs or tmpfs (Linux 5.8 or later), which waits for every pending write on that filesystem, including any holders'
|
||||
data there. Starts took from about 20 seconds to over 150 seconds in our shared-filesystem tests (one start was not
|
||||
ready after 2 minutes); this is not an upper bound. A volume whose lease expires stops serving until blockmaster is
|
||||
back; it is then granted again on the same holder, with its data. A forced move during that time can lose writes
|
||||
after the last published HEAD (see [forced move](volume-lifecycle.md#after-a-crash)). Restart blockmaster at low
|
||||
write load on the state filesystem, including when the cluster spec has not changed. v1.1.1 still syncs ancestors
|
||||
through `/`; its [restart known issue](releases/v1.1.1.md#known-issue-blockmaster-restart-can-stall-on-a-busy-filesystem)
|
||||
retains the earlier isolation guidance.
|
||||
|
||||
1. **Get the repository at the release tag, then the binaries.** The repository holds the units in `deploy/`. The
|
||||
binaries are `blockmaster`, `blockvolume` and `sw-block`, all three from the same release. `TAG` is the release,
|
||||
@@ -906,16 +958,34 @@ two hosts, follow the host-by-host order there. Where SeaweedFS was already runn
|
||||
```
|
||||
|
||||
3. **Remove sw-block.** The removal runs only after the same check succeeds in the same command. A failed query
|
||||
removes nothing:
|
||||
removes nothing. If section 1 put blockmaster's state on its own filesystem, empty and unmount it first, then
|
||||
delete its persistent mount configuration (its `/etc/fstab` line): `rm -rf` cannot remove a mount point, so
|
||||
the removal below would stop there. Unmount anything else mounted below these directories first, bind mounts
|
||||
included. `-xdev` and `--one-file-system` stop only at another filesystem: a bind mount from the same
|
||||
filesystem looks like a plain directory to them, and its source's contents would be deleted. Both commands
|
||||
below print nested mounts and remove nothing while one remains; `findmnt` lists the mounts. The final
|
||||
removal also refuses mounts at the operand roots themselves. The empty-and-unmount step intentionally
|
||||
allows blockmaster's state mount itself so it can empty and unmount that filesystem first.
|
||||
|
||||
```sh
|
||||
units=$(systemctl list-units 'sw-blockvolume*' 'sw-blockmaster*' --state=active,activating,deactivating --no-legend) &&
|
||||
test -z "$units" &&
|
||||
sudo rm -rf /var/lib/sw-block-volume /var/lib/sw-block-master /etc/sw-block &&
|
||||
test -z "$units" && mounts=$(findmnt -rno TARGET) &&
|
||||
! printf '%s\n' "$mounts" | grep -E '^/(var/lib/sw-block-(volume|master)|etc/sw-block)/' &&
|
||||
mountpoint -q /var/lib/sw-block-master &&
|
||||
sudo find /var/lib/sw-block-master -xdev -mindepth 1 -delete && sudo umount /var/lib/sw-block-master
|
||||
```
|
||||
|
||||
Then remove everything else:
|
||||
|
||||
```sh
|
||||
units=$(systemctl list-units 'sw-blockvolume*' 'sw-blockmaster*' --state=active,activating,deactivating --no-legend) &&
|
||||
test -z "$units" && mounts=$(findmnt -rno TARGET) &&
|
||||
! printf '%s\n' "$mounts" | grep -E '^/(var/lib/sw-block-(volume|master)|etc/sw-block)(/|$)' &&
|
||||
sudo rm -rf --one-file-system /var/lib/sw-block-volume /var/lib/sw-block-master /etc/sw-block &&
|
||||
sudo rm -f /etc/systemd/system/sw-blockmaster.service /etc/systemd/system/sw-blockvolume.service \
|
||||
/etc/systemd/system/sw-blockvolume@.service /etc/systemd/system/sw-blockvolume-ublk.service \
|
||||
/etc/tmpfiles.d/sw-block.conf /usr/local/bin/blockmaster /usr/local/bin/blockvolume /usr/local/bin/sw-block &&
|
||||
sudo rm -rf /etc/systemd/system/sw-blockvolume@*.service.d /run/sw-block &&
|
||||
sudo rm -rf /etc/systemd/system/sw-blockvolume@*.service.d /etc/systemd/system/sw-blockmaster.service.d /run/sw-block &&
|
||||
sudo systemctl daemon-reload && sudo userdel sw-block
|
||||
sudo rmdir /mnt/v1 /mnt/v2 2>/dev/null || true # the guest mount points (section 5's restore target too), if empty
|
||||
```
|
||||
|
||||
@@ -33,8 +33,7 @@ writing guest:
|
||||
`sw-block ops volumes --master-api <addr> -o json`, and if the primary moved, repeat the failover against it. A
|
||||
read shows the line at that moment only: blockmaster applies the queued rebalance when its assignment queue reaches
|
||||
it, not at a fixed time, so the primary can still move after any read, and the guest is then started again on the
|
||||
new primary (item 4). Fixed in v1.1.2: blockmaster refuses a queued rebalance or failover when the volume's line
|
||||
moved after it was decided.
|
||||
new primary (item 4).
|
||||
|
||||
**Planned for a later release.** Supported replicated volumes are planned for a later release; v1.1.x keeps every replicated
|
||||
configuration a preview. Replicated volumes are a preview: a primary cut off from the block master is not stopped
|
||||
|
||||
@@ -57,7 +57,7 @@ v1.1.1 is a fix release of the v1.1 line. None of its changes alters a stored fo
|
||||
- Affects replicated volumes (preview) whose acknowledgement profile allows a planned move: `sync-all`, or `sync-quorum` with two replicas.
|
||||
- blockmaster may decide an automatic rebalance, which moves the primary to a less loaded server, just before an operator's `sw-block ops failover`. If that rebalance is applied after the failover, it moves the primary again, away from the replica the operator chose.
|
||||
- No acknowledged write is lost: under these profiles every replica holds every acknowledged write.
|
||||
- What to do: after `sw-block ops failover`, read the volume's line with `sw-block ops volumes --master-api <addr> -o json`; if `primary_replica` moved again, repeat the failover with `--expect-current <primary_replica>@<epoch>`. No read confirms that the primary stays: blockmaster applies the queued rebalance when its assignment queue reaches it, not at a fixed time, so it can still move the primary after any read, and the guest is then started again on the new primary. Fixed in v1.1.2: blockmaster refuses a queued rebalance or failover when the volume's line moved after it was decided, so one decided before an operator's failover is no longer applied after it. A rebalance decided after the failover can still move the primary, as any rebalance can.
|
||||
- What to do: after `sw-block ops failover`, read the volume's line with `sw-block ops volumes --master-api <addr> -o json`; if `primary_replica` moved again, repeat the failover with `--expect-current <primary_replica>@<epoch>`. No read confirms that the primary stays: blockmaster applies the queued rebalance when its assignment queue reaches it, not at a fixed time, so it can still move the primary after any read, and the guest is then started again on the new primary. A fix is planned for a later v1.1.x release.
|
||||
|
||||
## Known issue: resuming an interrupted snapshot delete can stop the volume's snapshot deletes and cleaning
|
||||
|
||||
|
||||
@@ -2,18 +2,11 @@
|
||||
|
||||
v1.1.2 is not yet released.
|
||||
|
||||
## Fixed
|
||||
|
||||
- **Replicated volumes (preview): a queued rebalance no longer undoes an operator failover.** blockmaster's automatic
|
||||
rebalance and failover name the volume's line they were decided against, and blockmaster refuses one when that line
|
||||
moved since (another replica or epoch, or other addresses). A rebalance decided just before `sw-block ops failover`
|
||||
is no longer applied after it. This was a v1.1.1 known issue.
|
||||
|
||||
## Known issue: blockmaster restart can stall on a busy filesystem
|
||||
|
||||
- **Trigger:** blockmaster's state directory or its ancestors share a filesystem with heavy writes, such as the holders' local data.
|
||||
- **Trigger:** blockmaster's state filesystem also holds heavy writes, such as the holders' local data.
|
||||
- **Effect:** blockmaster's start syncs its state directories, which can wait for the filesystem journal. When the import has changed records, it also runs a `syncfs` for each store with changed records on ext4, XFS, btrfs or tmpfs (Linux 5.8 or later), which waits for every pending write on that filesystem, including the holders' data. Starts took from about 20 seconds to over 150 seconds in our tests (one start was not ready after 2 minutes); this is not an upper bound. A volume whose lease expires stops serving until blockmaster is back; it is then granted again on the same holder, with its data. A forced move during that time can lose writes after the last published HEAD (see [forced move](../volume-lifecycle.md#after-a-crash)).
|
||||
- **What to do:** keep the holders' data off both the state directory's filesystem and the filesystem holding its ancestor directories. In practice, put the holders' data on its own filesystem, not the root filesystem. A different directory on the same filesystem is not enough. A dedicated state-directory mount alone does not isolate every startup sync: opening the store also syncs ancestors up to `/`, including `/var/lib` and `/var` with the shipped layout. Restart blockmaster at low write load on all those filesystems. This limitation also applies when the cluster spec has not changed.
|
||||
- **What to do:** In v1.1.2, with the state directory on its own filesystem, blockmaster's start no longer syncs any directory on the shared filesystem. Under one buffered-write load, three starts per case measured shared warm/cold medians of 31.3/122.9 seconds and dedicated medians of 1.6/2.5 seconds, with a dedicated warm maximum of 13.2 seconds. Warm directory fsyncs fell from 30 to 15; shared root-filesystem directory fsyncs fell from 30 to 0. These are measurements under that load, not a start-time promise. Run `sync` after creating and mounting it. For a new install, install the units, then mount it and configure its persistent mount and the unit's mount dependency before the first start. Migrating existing state stops service; volumes fence once the downtime outlasts their leases. Stop and disable blockmaster (with v1.1.0 volume units, stop and disable the host's volumes first), copy all state preserving ownership and permissions, verify and sync the copy, then move the unmounted original directory aside (if it is a mount point itself, unmount it, keep that filesystem as the backup, and move the directory it uncovers aside too) and create an empty mount point. Configure the persistent mount and the unit's `RequiresMountsFor` plus `AssertPathIsMountPoint` drop-in, mount the copy, verify its stores and run `sync`. Enable and start blockmaster and confirm that it opens the copied stores and reloads existing records; only then remove the moved original. Never leave stale stores beneath the mount or start against an empty replacement. Follow the [state migration steps](../operations-manual.md#1-install-the-binaries-and-units). Keep holders' data off that filesystem; a different directory on it is not enough. Restart blockmaster at low write load on the state filesystem, including when the cluster spec has not changed. If device lookup fails, a logged fallback retains the full ancestor walk.
|
||||
|
||||
## Lifecycle persistence failures
|
||||
|
||||
|
||||
Reference in new issue
Block a user