Compare commits

..
Author SHA1 Message Date
Ping Qiu 50059133d4 Merge branch 'master' into block/controller-replace-reaches-reassign 2026-12-05 17:15:21 -08:00
Ping Qiu 514e7b8a54 Merge branch 'master' into block/controller-replace-reaches-reassign 2026-12-05 16:37:40 -08:00
pingqiuandClaude Opus 5.5 ca6cf4eacb seaweed-block: docs: the v1.1.2 fix covers moves decided before the failover
Review: a rebalance decided after an operator's failover names the new
line and can still move the primary; the fixed-in note now covers only
a move decided before the failover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 16:15:09 -08:00
pingqiuandClaude Opus 5.5 bca02f467d seaweed-block: docs: the expected-line check compares addresses only when the ask names them
Review: expectedLineMoved treats an empty expected address as a wildcard,
and an operator's failback names replica and epoch only, so an endpoint
move to other addresses does not refuse a failback. The Reassigned row
now says the address comparison applies only to asks that name them (the
controller's moves).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 16:10:38 -08:00
pingqiuandClaude Opus 5.5 4c2db0e423 seaweed-block: docs: the queued-rebalance known issue is fixed in v1.1.2
blockmaster's rebalance and failover now name the line they were decided
against and are refused when it moved: the v1.1.1 known issue and the
replicated preview's item 6 say it is fixed in v1.1.2, and the v1.1.2
notes list the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 16:01:37 -08:00
pingqiuandClaude Opus 5.5 1c260e2c7b seaweed-block: docs: the Reassigned row states what the expected-line check compares
Review: expectedLineMoved compares replica, epoch and addresses, so a
same-address endpoint reissue (new endpoint version or incarnation)
still matches and a queued move decided before it publishes; the
move's epoch bump fences the reissued line. The row now says so instead
of claiming every later publication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 15:42:35 -08:00
Chris LuandClaude Opus 5.5 af38a640d1 seaweed-block: docs: a Reassign is refused when its expected line moved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 15:14:16 -08:00
Chris LuandClaude Opus 5.5 183aee800c seaweed-block: a controller Reassign names the line it was decided against
The rebalance and failover asks carry ExpectCurrent, as the controller's
endpoint refresh already does, so the publisher refuses one whose line
moved while it waited in the queue. A refused ask ends without a
publication and the next intake decides again against the new line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 15:13:28 -08:00
Chris LuandClaude Opus 5.5 b85a870c03 seaweed-block: red: a queued Reassign overwrites a later publication
A controller Reassign waits in the queue until the publisher takes it. A
failback published outside the queue in that window is overwritten by
the ask decided against the older line, both for a first ask and for a
lost one enqueued again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 15:13:28 -08:00
Chris LuandClaude Opus 5.5 5ed8a644dc Merge remote-tracking branch 'origin/master' into block/controller-replace-reaches-reassign
#13428 squash-merged as 10b949183, whose tree equals the branch's #13428
head aeae2b5f, so the merge keeps this branch's tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 14:40:32 -08:00
pingqiu f6e4f59d79 Merge branch 'block/controller-outcome-log' into block/controller-replace-reaches-reassign 2026-12-05 12:45:28 -08:00
pingqiu aeae2b5f7b Merge remote-tracking branch 'origin/master' into block/controller-outcome-log 2026-12-05 12:39:54 -08:00
Chris LuandClaude Opus 5.5 476001be77 seaweed-block: mark the PromoLive r6 citations as checked outside the repository (on #13435) (#13442)
seaweed-block: mark the PromoLive r6 citations as checked outside the repository

The convention says a TLA+ entry names a specification in docs/spec/,
and PromoLive r6 is not there.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 11:30:49 -08:00
pingqiuandClaude Opus 5.5 64529e87c8 seaweed-block: the controller-ask rows cite the promotion liveness model r6
The model now splits the intake as the code does (read the line and decide;
enqueue only if the ask is not pending and the line is unchanged). It
holds RoundProgress and QueuedMatchesLine and catches the mutants
dedupe_keeps_lost, predicate_split and nonatomic_submit. The four rows and
the M2 controller-ask section name them; the retry window and Stuck are not
modelled, and the rows say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 02:00:28 -08:00
pingqiu c380e49e23 Merge remote-tracking branch 'origin/followup-13435-published-ask-recheck' into block/controller-replace-reaches-reassign
# Conflicts:
#	seaweed-block/docs/design/invariants.md
2026-12-05 01:42:25 -08:00
pingqiu fe262f7e28 Merge branch 'block/controller-outcome-log' into block/controller-replace-reaches-reassign
# Conflicts:
#	seaweed-block/docs/design/invariants.md
2026-12-05 01:41:55 -08:00
Chris LuandClaude Opus 5.5 9fea81e88a seaweed-block: docs: split the controller-ask contract rows to one property each
INV-AUTH-DESIRED-RETRY-001 (346 characters) and
INV-PROMOTE-REPLACE-HANDOFF-001 (459) were over the 300-character
statement limit TestInvariantStatementsAreShort enforces. Each becomes two
rows; the lost-ask row also names the published-during-intake regression
and its line re-read guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:32:19 -08:00
Chris LuandClaude Opus 5.5 a0e484dba1 seaweed-block: gateNoteMu also guards gateReplaces
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:31:52 -08:00
Chris LuandClaude Opus 5.5 0687c4d5b2 seaweed-block: a desired ask published during the intake is not enqueued again
The lost-ask retry read "not pending" as "ended without a publication",
but the publisher also stops holding an ask once it has published it and
asked for the next one. When that happens between the line read the intake
decided against and the dedupe, re-read the line: the ask is lost only
while the line is still the one it was decided against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:31:00 -08:00
Chris LuandClaude Opus 5.5 6635e3b378 seaweed-block: split the replace-decision ledger row under the statement limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:29:56 -08:00
Chris LuandClaude Opus 5.5 d975b7a874 seaweed-block: red: an ask published during the intake is enqueued again
The publisher can publish the desired ask and come back for its next one
between the line read an intake decides against and that intake's same-ask
dedupe. The queue then holds nothing for the volume, so the dedupe reads
the ask as lost and enqueues it again; a planned move carries no fence, so
the publisher would mint it a second time at a new epoch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:29:50 -08:00
pingqiuandClaude Opus 5.5 205e40cf54 seaweed-block: the desired-ask retry keeps its DesiredAt to Stuck; contract rows
Review round 2 (both P2s):
- TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck runs four
  take -> ended-without-publication -> re-enqueue cycles across the retry
  window: DesiredAt stays the first desire and the Stuck evidence names it.
  A retry that re-anchors DesiredAt fails it.
- docs/design/invariants.md: M2 gains the controller-ask machine between
  the promotion gate and the publisher (queued, held, lost, re-enqueued,
  Stuck; the fenced-replace handoff), with its diagram, and the rows
  INV-AUTH-DESIRED-RETRY-001 and INV-PROMOTE-REPLACE-HANDOFF-001 naming the
  regression tests. No published specification models this handoff; the
  rows say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:05:20 -08:00
pingqiu 290049b1bf Merge branch 'block/controller-outcome-log' into block/controller-replace-reaches-reassign 2026-12-05 01:01:29 -08:00
pingqiuandClaude Opus 5.5 92d75b099b seaweed-block: ledger row for the replace-decision report
Review round 2: Part C rule 4. INV-PROMOTE-DECISION-REPORTED-001 names the
regression tests this change adds (an intake after the submission, the
binding-read failure after the probe) and their enforcing functions.
Diagnostics only: no state machine or model change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:45:25 -08:00
pingqiuandClaude Opus 5.5 98b3104ad5 seaweed-block: a fenced replace always reaches the controller as a failover, and a lost Reassign is enqueued again
The gate marks the replaced primary's slot unacceptable in what it submits
on every fenced replace, not only when a loss is recorded. A primary only
the gate rejects (a node below the cluster's format level) was kept by the
controller's own acceptability predicate on every tick.

The same-ask dedupe holds a desired ask only while it is pending: queued,
or taken by the publisher and still being applied (the queue records the
ask the publisher holds until it asks for the next one). An identical ask
that is neither ended without a publication and is enqueued again, keeping
its DesiredAt so a repeatedly lost ask still reports Stuck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:13:55 -08:00
pingqiuandClaude Opus 5.5 860602beaa seaweed-block: red: a gate replace the controller keeps, and a lost Reassign held for ever
Two reds for the master's fenced replace that never publishes.

A primary only the gate rejects (its node reads an older format level,
its own flags still read reachable and ready, no loss recorded) is
replaced by a fencing round on every tick, and the controller answers
"no ask: the current primary is acceptable" on every tick.

A Reassign the publisher took and ended without publishing is lost, and
the same-ask dedupe answers "already desired" on every later intake, so
nothing enqueues it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:13:38 -08:00
pingqiuandClaude Opus 5.5 e2849ba53d seaweed-block: a replace decision is reported with its own submission's outcome, and on a binding-read failure
Review round 1:
- The tick reads the controller's outcome for each volume inside the
  intake that carried it (SubmitObservedStateOutcomes, under the
  controller's lock): the background observation host shares the
  controller and may submit before a later read.
- A workspace binding read that fails after the probe reports the tick's
  replace decisions as not submitted, with the error, before returning.
- The production-tick test waits for the publication line (bounded): the
  publisher logs it from its observer after the line is visible.
- A replace decision is identified by a flag set where it is decided, not
  by its display text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:11:11 -08:00
pingqiuandClaude Opus 5.5 3b6f67e51a fix(master): a promotion gate's replace decision logs what the controller did with it
A replace decided by the promotion gate went to the topology controller,
which can drop it on six paths without a word. These are: a stale basis,
superseded slot facts, a boot-grace hold, no evidence on the target, an
ask that is already desired, and an unsupported topology. When a volume
then did not fail over, nothing on the master's log said why.

The controller now records, per volume, what its last intake did: the ask
it enqueued, or why it enqueued none (LastOutcome). After each tick's
submit, the master logs every replace decision with that outcome, or with
why the decisions were not submitted. Every publication is logged too.

The creation-gap process test derives its failover bound from its own
flags: one loop to the tick that ends creation, plus the freshness window
to the loss, plus one loop to the tick that reads it. It waits twice that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 23:23:44 -08:00
10 changed files with 427 additions and 30 deletions

No files matched your search

+45 -20
View File
@@ -327,12 +327,28 @@ func (c *TopologyController) processSupportedVolumeLocked(
c.outcome[vol.VolumeID] = "no ask: " + reason
return
}
// 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.
// 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.
if prev, ok := c.desired[vol.VolumeID]; ok && sameAsk(prev.Ask, 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)
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)
return
}
@@ -550,13 +566,14 @@ 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,
VolumeID: vol.VolumeID,
ReplicaID: target.ReplicaID,
DataAddr: target.DataAddr,
CtrlAddr: target.CtrlAddr,
Intent: IntentReassign,
Evidence: plannedEvidence(target.PromotionEvidence),
Incarnation: target.Incarnation,
ExpectCurrent: expectedLineOf(currentLine),
}, "rebalance", true
}
return AssignmentAsk{}, "the current primary is acceptable", false
@@ -583,13 +600,14 @@ 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,
VolumeID: vol.VolumeID,
ReplicaID: best.ReplicaID,
DataAddr: best.DataAddr,
CtrlAddr: best.CtrlAddr,
Intent: IntentReassign,
Evidence: best.PromotionEvidence,
Incarnation: best.Incarnation,
ExpectCurrent: expectedLineOf(currentLine),
}, "failover", true
}
why = "failover target " + best.ReplicaID + " has no promotion evidence"
@@ -623,10 +641,17 @@ func refreshAsk(volumeID string, current ReplicaCandidate, line AuthorityBasis)
CtrlAddr: current.CtrlAddr,
Intent: IntentRefreshEndpoint,
Incarnation: current.Incarnation,
ExpectCurrent: &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr},
ExpectCurrent: expectedLineOf(line),
}
}
// 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 {
@@ -0,0 +1,252 @@
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)
}
}
}
+17
View File
@@ -14,6 +14,10 @@ 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 {
@@ -42,7 +46,19 @@ 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 {
@@ -54,6 +70,7 @@ func (q *assignmentQueue) next(ctx context.Context) (AssignmentAsk, error) {
continue
}
delete(q.items, vid)
q.taken = vid
q.mu.Unlock()
return ask, nil
}
@@ -0,0 +1,60 @@
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,12 +500,15 @@ func (h *Host) applyPromotionEvidenceGate(snap *authority.ClusterSnapshot) (int,
slot.PlannedMoveAllowed = false
}
}
// 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
// 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
// routing the target as a planned rebalance without that epoch.
if lost && fencedReplace {
if fencedReplace {
current := &vol.Slots[currentIdx]
current.Reachable, current.ReadyForPrimary = false, false
}
+34 -2
View File
@@ -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. 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; 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)).
- 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 | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `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; 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` |
| 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,6 +201,34 @@ 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
@@ -1010,6 +1038,8 @@ 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 |
@@ -1382,6 +1412,8 @@ 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 |
@@ -33,7 +33,8 @@ 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).
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.
**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
+1 -1
View File
@@ -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. A fix is planned for a later v1.1.x release.
- 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.
## Known issue: resuming an interrupted snapshot delete can stop the volume's snapshot deletes and cleaning
+7
View File
@@ -2,6 +2,13 @@
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.
+1 -1
View File
@@ -487,8 +487,8 @@ func (f *Filer) rebuildRemoteDeletionTombstones(ctx context.Context, mounts []ut
ctx = context.WithValue(ctx, lazyFetchContextKey{}, true)
startTsNs := f.remoteDeletionRebuildStartTsNs(ctx, mounts)
openGate := func() {
f.remoteTombstonesDone.Store(nil)
close(done)
f.remoteTombstonesDone.Store(nil)
}
// Deletes made after startup are recorded through the live delete and
// event paths, so replay can only be missing deletes committed before