mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
authority: a restarted primary is re-issued its line at a new endpoint version
A primary restarted at the same epoch and address started its sessions at 1 while each replica held the dead process's higher one, so every session was refused as older. The line now records the process it was issued for (durable); a current primary reporting another process is re-issued its line at the next endpoint version, and a primary adopts no line issued for another process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9c4c57b43
commit
18f39b9646
15 files changed
+1090
-669
No files matched your search
@@ -38,6 +38,11 @@ type AssignmentInfo struct {
|
||||
// evidence the master probed on the target; the target checks it before
|
||||
// adopting the role. The zero value is a line without a kind.
|
||||
Primary PrimaryEvidence
|
||||
// Incarnation is the primary process this line was issued for (its
|
||||
// reported incarnation when the line was minted; "" = not known). It is
|
||||
// compared only for equality: a primary that finds another one on its
|
||||
// line is a restarted process the master has not re-issued yet.
|
||||
Incarnation string
|
||||
}
|
||||
|
||||
// PrimaryKind is how a line made its primary the primary.
|
||||
|
||||
@@ -288,6 +288,7 @@ func (p *Publisher) reloadFromStore() {
|
||||
EndpointVersion: rec.EndpointVersion,
|
||||
DataAddr: rec.DataAddr,
|
||||
CtrlAddr: rec.CtrlAddr,
|
||||
Incarnation: rec.Incarnation,
|
||||
},
|
||||
present: true,
|
||||
}
|
||||
@@ -540,6 +541,7 @@ func (p *Publisher) applyWithWorkspaceMove(ask AssignmentAsk, grant *workspaceGr
|
||||
DataAddr: ask.DataAddr,
|
||||
CtrlAddr: ask.CtrlAddr,
|
||||
Primary: adapter.PrimaryEvidence{Kind: adapter.PrimaryKindBootstrap},
|
||||
Incarnation: ask.Incarnation,
|
||||
}
|
||||
|
||||
case IntentRefreshEndpoint:
|
||||
@@ -547,16 +549,23 @@ func (p *Publisher) applyWithWorkspaceMove(ask AssignmentAsk, grant *workspaceGr
|
||||
p.mu.Unlock()
|
||||
return ErrRefreshNotBound
|
||||
}
|
||||
if prev.info.DataAddr == ask.DataAddr && prev.info.CtrlAddr == ask.CtrlAddr {
|
||||
restarted := ask.Incarnation != "" && ask.Incarnation != prev.info.Incarnation
|
||||
if prev.info.DataAddr == ask.DataAddr && prev.info.CtrlAddr == ask.CtrlAddr && !restarted {
|
||||
// Idempotent no-op. Do not fan out, do not log as
|
||||
// rejection — the directive is allowed to retry.
|
||||
p.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
// New addresses, or a restarted primary process at the same ones:
|
||||
// a new endpoint version, so every session the new process opens
|
||||
// outranks the dead process's on each replica.
|
||||
next = prev.info
|
||||
next.EndpointVersion = prev.info.EndpointVersion + 1
|
||||
next.DataAddr = ask.DataAddr
|
||||
next.CtrlAddr = ask.CtrlAddr
|
||||
if ask.Incarnation != "" {
|
||||
next.Incarnation = ask.Incarnation
|
||||
}
|
||||
|
||||
case IntentReassign:
|
||||
// A primary change carries how it was decided (a kind, and for a
|
||||
@@ -594,6 +603,7 @@ func (p *Publisher) applyWithWorkspaceMove(ask AssignmentAsk, grant *workspaceGr
|
||||
DataAddr: ask.DataAddr,
|
||||
CtrlAddr: ask.CtrlAddr,
|
||||
Primary: ask.Evidence,
|
||||
Incarnation: ask.Incarnation,
|
||||
}
|
||||
if reservedEpoch != 0 {
|
||||
next.Epoch = reservedEpoch
|
||||
@@ -642,6 +652,7 @@ func (p *Publisher) applyWithWorkspaceMove(ask AssignmentAsk, grant *workspaceGr
|
||||
CtrlAddr: next.CtrlAddr,
|
||||
WriteSeq: nextSeq,
|
||||
Workspace: cloneWorkspace(p.workspace[ask.VolumeID]),
|
||||
Incarnation: next.Incarnation,
|
||||
}
|
||||
if next.Primary != (adapter.PrimaryEvidence{}) {
|
||||
pe := next.Primary
|
||||
|
||||
@@ -54,6 +54,9 @@ type DurableRecord struct {
|
||||
// carries what the first publication carried. Omitting nil preserves the
|
||||
// checksum of records written before it.
|
||||
Primary *adapter.PrimaryEvidence `json:",omitempty"`
|
||||
// Incarnation is the primary process the line was issued for. Omitting
|
||||
// "" preserves the checksum of records written before it.
|
||||
Incarnation string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// AuthorityStore is the narrow durable-authority interface. The
|
||||
|
||||
@@ -432,7 +432,8 @@ func desiredObserved(desired DesiredAssignment, vol VolumeTopologySnapshot, curr
|
||||
switch desired.Ask.Intent {
|
||||
case IntentRefreshEndpoint:
|
||||
return vol.Authority.DataAddr == desired.Ask.DataAddr &&
|
||||
vol.Authority.CtrlAddr == desired.Ask.CtrlAddr
|
||||
vol.Authority.CtrlAddr == desired.Ask.CtrlAddr &&
|
||||
(desired.Ask.Incarnation == "" || currentLine.Incarnation == desired.Ask.Incarnation)
|
||||
case IntentBind, IntentReassign:
|
||||
return true
|
||||
default:
|
||||
@@ -471,11 +472,12 @@ func (c *TopologyController) decideVolume(
|
||||
}
|
||||
best := choosePlacementCandidate(cands, projectedLoad)
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: best.ReplicaID,
|
||||
DataAddr: best.DataAddr,
|
||||
CtrlAddr: best.CtrlAddr,
|
||||
Intent: IntentBind,
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: best.ReplicaID,
|
||||
DataAddr: best.DataAddr,
|
||||
CtrlAddr: best.CtrlAddr,
|
||||
Intent: IntentBind,
|
||||
Incarnation: best.Incarnation,
|
||||
}, "initial placement", true
|
||||
}
|
||||
|
||||
@@ -485,14 +487,8 @@ func (c *TopologyController) decideVolume(
|
||||
}
|
||||
|
||||
if candidateAcceptable(current, serverIndex) {
|
||||
if current.DataAddr != currentLine.DataAddr || current.CtrlAddr != currentLine.CtrlAddr {
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: current.ReplicaID,
|
||||
DataAddr: current.DataAddr,
|
||||
CtrlAddr: current.CtrlAddr,
|
||||
Intent: IntentRefreshEndpoint,
|
||||
}, "endpoint refresh", true
|
||||
if endpointStale(current, currentLine) {
|
||||
return refreshAsk(vol.VolumeID, current), "endpoint refresh", true
|
||||
}
|
||||
if target, ok := chooseRebalanceCandidate(vol, current, serverIndex, currentLoad, projectedLoad, c.config.RebalanceSkew); ok {
|
||||
// A primary change goes out only with the promotion gate's
|
||||
@@ -503,12 +499,13 @@ func (c *TopologyController) decideVolume(
|
||||
return AssignmentAsk{}, "", false
|
||||
}
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: target.ReplicaID,
|
||||
DataAddr: target.DataAddr,
|
||||
CtrlAddr: target.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: plannedEvidence(target.PromotionEvidence),
|
||||
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{}, "", false
|
||||
@@ -518,14 +515,8 @@ func (c *TopologyController) decideVolume(
|
||||
// keeps its authority through its boot grace; only its endpoint
|
||||
// may be refreshed.
|
||||
if hold, superseded := c.primaryBootGraceLocked(vol.VolumeID, current, candidatePlaceable(current, serverIndex)); hold {
|
||||
if !superseded && (current.DataAddr != currentLine.DataAddr || current.CtrlAddr != currentLine.CtrlAddr) {
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: current.ReplicaID,
|
||||
DataAddr: current.DataAddr,
|
||||
CtrlAddr: current.CtrlAddr,
|
||||
Intent: IntentRefreshEndpoint,
|
||||
}, "endpoint refresh (primary boot grace)", true
|
||||
if !superseded && endpointStale(current, currentLine) {
|
||||
return refreshAsk(vol.VolumeID, current), "endpoint refresh (primary boot grace)", true
|
||||
}
|
||||
return AssignmentAsk{}, "", false
|
||||
}
|
||||
@@ -537,31 +528,47 @@ 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,
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: best.ReplicaID,
|
||||
DataAddr: best.DataAddr,
|
||||
CtrlAddr: best.CtrlAddr,
|
||||
Intent: IntentReassign,
|
||||
Evidence: best.PromotionEvidence,
|
||||
Incarnation: best.Incarnation,
|
||||
}, "failover", true
|
||||
}
|
||||
}
|
||||
// No promotion-ready peer exists. Keep the current authority endpoint fresh
|
||||
// when the current replica is still reachable/eligible; this preserves
|
||||
// authority continuity without treating that replica as a failover candidate.
|
||||
if candidatePlaceable(current, serverIndex) &&
|
||||
(current.DataAddr != currentLine.DataAddr || current.CtrlAddr != currentLine.CtrlAddr) {
|
||||
return AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: current.ReplicaID,
|
||||
DataAddr: current.DataAddr,
|
||||
CtrlAddr: current.CtrlAddr,
|
||||
Intent: IntentRefreshEndpoint,
|
||||
}, "endpoint refresh", true
|
||||
if candidatePlaceable(current, serverIndex) && endpointStale(current, currentLine) {
|
||||
return refreshAsk(vol.VolumeID, current), "endpoint refresh", true
|
||||
}
|
||||
return AssignmentAsk{}, "", false
|
||||
}
|
||||
|
||||
// endpointStale reports whether the current primary's line needs a new
|
||||
// endpoint version: its addresses changed, or the process reporting it is
|
||||
// not the one the line was issued for (a restarted primary, compared for
|
||||
// equality only; the order stays the endpoint version).
|
||||
func endpointStale(current ReplicaCandidate, line AuthorityBasis) bool {
|
||||
return current.DataAddr != line.DataAddr || current.CtrlAddr != line.CtrlAddr ||
|
||||
current.Incarnation != "" && current.Incarnation != line.Incarnation
|
||||
}
|
||||
|
||||
// refreshAsk re-issues the current primary's line at its reported
|
||||
// addresses for its reported incarnation.
|
||||
func refreshAsk(volumeID string, current ReplicaCandidate) AssignmentAsk {
|
||||
return AssignmentAsk{
|
||||
VolumeID: volumeID,
|
||||
ReplicaID: current.ReplicaID,
|
||||
DataAddr: current.DataAddr,
|
||||
CtrlAddr: current.CtrlAddr,
|
||||
Intent: IntentRefreshEndpoint,
|
||||
Incarnation: current.Incarnation,
|
||||
}
|
||||
}
|
||||
|
||||
func volumeIncludesReplica(vol VolumeTopologySnapshot, replicaID string) bool {
|
||||
for _, slot := range vol.Slots {
|
||||
if slot.ReplicaID == replicaID {
|
||||
|
||||
@@ -74,6 +74,11 @@ type AssignmentAsk struct {
|
||||
// target (a bind is always a bootstrap); see adapter.PrimaryEvidence. It
|
||||
// is a probe fact about the target, never an authority fact.
|
||||
Evidence adapter.PrimaryEvidence
|
||||
// Incarnation is the target's reported process incarnation in the facts
|
||||
// the decision used ("" = not reported). A refresh whose incarnation
|
||||
// differs from the line's is a restarted primary: a new endpoint version
|
||||
// even at the same addresses.
|
||||
Incarnation string
|
||||
}
|
||||
|
||||
// ErrReassignWithoutKind: a primary change was asked without a kind (no
|
||||
|
||||
@@ -39,6 +39,9 @@ type AuthorityBasis struct {
|
||||
EndpointVersion uint64
|
||||
DataAddr string
|
||||
CtrlAddr string
|
||||
// Incarnation is the primary process the line was issued for ("" = not
|
||||
// known); see adapter.AssignmentInfo.Incarnation.
|
||||
Incarnation string
|
||||
}
|
||||
|
||||
// AuthorityBasisReader exposes read-only views of the publisher's
|
||||
@@ -74,6 +77,7 @@ func (p *Publisher) LastAuthorityBasis(volumeID, replicaID string) (AuthorityBas
|
||||
EndpointVersion: info.EndpointVersion,
|
||||
DataAddr: info.DataAddr,
|
||||
CtrlAddr: info.CtrlAddr,
|
||||
Incarnation: info.Incarnation,
|
||||
}, true
|
||||
}
|
||||
|
||||
@@ -102,6 +106,7 @@ func (p *Publisher) VolumeAuthorityLine(volumeID string) (AuthorityBasis, bool)
|
||||
EndpointVersion: st.info.EndpointVersion,
|
||||
DataAddr: st.info.DataAddr,
|
||||
CtrlAddr: st.info.CtrlAddr,
|
||||
Incarnation: st.info.Incarnation,
|
||||
}
|
||||
any = true
|
||||
}
|
||||
|
||||
@@ -9,21 +9,29 @@ import (
|
||||
// but not ready yet keeps its authority for one bounded grace.
|
||||
|
||||
type bootGraceRig struct {
|
||||
t *testing.T
|
||||
ctrl *TopologyController
|
||||
now time.Time
|
||||
rev uint64
|
||||
t *testing.T
|
||||
ctrl *TopologyController
|
||||
reader *fakeBasisReader
|
||||
now time.Time
|
||||
rev uint64
|
||||
// reissued models the publisher having re-issued r1's line for the
|
||||
// process that reports it (the restart refresh already applied), so a
|
||||
// test of the grace sees only the grace. Off, the line stays with the
|
||||
// process it was first issued for (r1-a).
|
||||
reissued bool
|
||||
line AuthorityBasis
|
||||
}
|
||||
|
||||
const testBootGrace = 30 * time.Second
|
||||
|
||||
func newBootGraceRig(t *testing.T) *bootGraceRig {
|
||||
reader := newFakeBasisReader()
|
||||
reader.Set("v1", "r1", AuthorityBasis{
|
||||
line := AuthorityBasis{
|
||||
Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1,
|
||||
DataAddr: "d1-old", CtrlAddr: "c1-old",
|
||||
})
|
||||
g := &bootGraceRig{t: t, now: time.Unix(1000, 0)}
|
||||
DataAddr: "d1-old", CtrlAddr: "c1-old", Incarnation: "r1-a",
|
||||
}
|
||||
reader.Set("v1", "r1", line)
|
||||
g := &bootGraceRig{t: t, now: time.Unix(1000, 0), reader: reader, reissued: true, line: line}
|
||||
g.ctrl = NewTopologyController(TopologyControllerConfig{PrimaryBootGrace: testBootGrace}, reader)
|
||||
g.ctrl.SetNowForTest(func() time.Time { return g.now })
|
||||
return g
|
||||
@@ -37,6 +45,10 @@ func (g *bootGraceRig) submit(r1 ReplicaCandidate) {
|
||||
if r1.ObservedAt.IsZero() {
|
||||
r1.ObservedAt = g.now
|
||||
}
|
||||
if g.reissued && r1.Incarnation != "" && r1.Incarnation != g.line.Incarnation {
|
||||
g.line.Incarnation = r1.Incarnation
|
||||
g.reader.Set("v1", "r1", g.line)
|
||||
}
|
||||
r2 := candidate("r2", "s2", "d2", "c2", 20)
|
||||
r2.Incarnation = "r2-a"
|
||||
r3 := candidate("r3", "s3", "d3", "c3", 10)
|
||||
@@ -48,9 +60,7 @@ func (g *bootGraceRig) submit(r1 ReplicaCandidate) {
|
||||
{ServerID: "s2", Reachable: true, Eligible: true},
|
||||
{ServerID: "s3", Reachable: true, Eligible: true},
|
||||
},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1",
|
||||
AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1-old", CtrlAddr: "c1-old"},
|
||||
r1, r2, r3)},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", g.line, r1, r2, r3)},
|
||||
}
|
||||
if err := g.ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
g.t.Fatalf("SubmitClusterSnapshot: %v", err)
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
package authority
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A restarted primary process (a new incarnation at the same addresses)
|
||||
// is re-issued its line at a new endpoint version: every session the new
|
||||
// process opens then outranks the dead process's on each replica. The same
|
||||
// process again changes nothing.
|
||||
func TestPublisher_RestartedPrimaryGetsANewEndpointVersion(t *testing.T) {
|
||||
pub := NewPublisher(NewStaticDirective(nil))
|
||||
bind := AssignmentAsk{VolumeID: "v1", ReplicaID: "r1", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind, Incarnation: "p1"}
|
||||
if err := pub.apply(bind); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, _ := pub.LastPublished("v1", "r1"); got.Incarnation != "p1" || got.EndpointVersion != 1 {
|
||||
t.Fatalf("bind: %+v; want incarnation p1 at EV 1", got)
|
||||
}
|
||||
refresh := AssignmentAsk{VolumeID: "v1", ReplicaID: "r1", DataAddr: "d", CtrlAddr: "c", Intent: IntentRefreshEndpoint}
|
||||
for _, c := range []struct {
|
||||
incarnation string
|
||||
ev uint64
|
||||
line string
|
||||
why string
|
||||
}{
|
||||
{"p1", 1, "p1", "the same process at the same addresses"},
|
||||
{"", 1, "p1", "a refresh that names no process"},
|
||||
{"p2", 2, "p2", "a restarted process at the same addresses"},
|
||||
{"p2", 2, "p2", "the restarted process again"},
|
||||
} {
|
||||
refresh.Incarnation = c.incarnation
|
||||
if err := pub.apply(refresh); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, _ := pub.LastPublished("v1", "r1")
|
||||
if got.Epoch != 1 || got.EndpointVersion != c.ev || got.Incarnation != c.line {
|
||||
t.Fatalf("%s: %+v; want epoch 1, EV %d, issued for %s", c.why, got, c.ev, c.line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The line remembers the process it was issued for across a master restart
|
||||
// (the durable record), so a restarted master neither re-issues the line of
|
||||
// a primary that did not restart nor misses one that restarted while the
|
||||
// master was down.
|
||||
func TestDurableAuthority_ReloadKeepsTheLinesIncarnation(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
storeA, err := NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pubA := NewPublisher(NewStaticDirective(nil), WithStore(storeA))
|
||||
if err := pubA.apply(AssignmentAsk{VolumeID: "v1", ReplicaID: "r1", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind, Incarnation: "p1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = storeA.Close()
|
||||
storeB, err := NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer storeB.Close()
|
||||
pubB := NewPublisher(NewStaticDirective(nil), WithStore(storeB))
|
||||
line, ok := pubB.VolumeAuthorityLine("v1")
|
||||
if !ok || line.Incarnation != "p1" || line.EndpointVersion != 1 {
|
||||
t.Fatalf("reloaded line %+v; want incarnation p1 at EV 1", line)
|
||||
}
|
||||
same := AssignmentAsk{VolumeID: "v1", ReplicaID: "r1", DataAddr: "d", CtrlAddr: "c", Intent: IntentRefreshEndpoint, Incarnation: "p1"}
|
||||
if err := pubB.apply(same); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, _ := pubB.LastPublished("v1", "r1"); got.EndpointVersion != 1 {
|
||||
t.Fatalf("after a master restart the same process was re-issued: EV %d", got.EndpointVersion)
|
||||
}
|
||||
restarted := same
|
||||
restarted.Incarnation = "p2" // the primary restarted while the master was down
|
||||
if err := pubB.apply(restarted); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, _ := pubB.LastPublished("v1", "r1"); got.EndpointVersion != 2 || got.Incarnation != "p2" {
|
||||
t.Fatalf("a primary restarted during the master's downtime: %+v; want EV 2 for p2", got)
|
||||
}
|
||||
}
|
||||
|
||||
// The controller asks to re-issue the current primary's line when the
|
||||
// process reporting it is not the one the line was issued for, ready or
|
||||
// inside its boot grace; the running process asks nothing.
|
||||
func TestTopologyController_RestartedPrimaryAtTheSameAddressIsReissued(t *testing.T) {
|
||||
for _, ready := range []bool{true, false} {
|
||||
g := newBootGraceRig(t)
|
||||
g.reissued = false
|
||||
g.steadyPrimary() // r1-a, the line's process: no ask
|
||||
g.submit(r1Slot("r1-b", "d1-old", "c1-old", ready))
|
||||
ask := nextAskOrFail(t, g.ctrl)
|
||||
if ask.Intent != IntentRefreshEndpoint || ask.ReplicaID != "r1" || ask.Incarnation != "r1-b" || ask.DataAddr != "d1-old" {
|
||||
t.Fatalf("restarted primary (ready=%v) at the same address: %+v; want a refresh of r1 for r1-b", ready, ask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cell: a late report of the dead process, after the line was re-issued
|
||||
// for the new one, re-issues nothing: exactly one new endpoint version.
|
||||
func TestTopologyController_LateReportOfTheDeadProcessReissuesNothing(t *testing.T) {
|
||||
g := newBootGraceRig(t)
|
||||
g.reissued = false
|
||||
g.steadyPrimary()
|
||||
restartedAt := g.now
|
||||
g.submit(r1Slot("r1-b", "d1-old", "c1-old", true))
|
||||
if ask := nextAskOrFail(t, g.ctrl); ask.Incarnation != "r1-b" {
|
||||
t.Fatalf("restart: %+v", ask)
|
||||
}
|
||||
g.line.Incarnation, g.line.EndpointVersion = "r1-b", 2 // the publisher re-issued it
|
||||
g.reader.Set("v1", "r1", g.line)
|
||||
g.now = g.now.Add(time.Second)
|
||||
g.submit(r1Slot("r1-b", "d1-old", "c1-old", true))
|
||||
expectNoNext(t, g.ctrl)
|
||||
late := r1Slot("r1-a", "d1-old", "c1-old", true)
|
||||
late.ObservedAt = restartedAt.Add(-time.Millisecond) // sent before the restart, delivered after
|
||||
g.now = g.now.Add(time.Second)
|
||||
g.submit(late)
|
||||
expectNoNext(t, g.ctrl)
|
||||
}
|
||||
|
||||
// Cell: a failover records the incarnation the decision saw for its
|
||||
// target. A target that restarts between the decision and its first report
|
||||
// as primary is re-issued once (a new endpoint version), never promoted
|
||||
// again.
|
||||
func TestTopologyController_TargetRestartedAfterThePromotionIsReissuedNotPromotedAgain(t *testing.T) {
|
||||
g := newBootGraceRig(t)
|
||||
g.steadyPrimary()
|
||||
g.now = g.now.Add(testBootGrace + time.Second)
|
||||
dead := r1Slot("r1-a", "d1-old", "c1-old", false)
|
||||
dead.Reachable, dead.ReadyForPrimary = false, false
|
||||
g.submit(dead)
|
||||
ask := nextAskOrFail(t, g.ctrl)
|
||||
if ask.Intent != IntentReassign || ask.ReplicaID != "r2" || ask.Incarnation != "r2-a" {
|
||||
t.Fatalf("failover: %+v; want a reassign to r2 recording r2-a", ask)
|
||||
}
|
||||
// Published: r2 holds the line, issued for r2-a. r2 restarts as r2-b
|
||||
// before it reports as primary.
|
||||
line := AuthorityBasis{Assigned: true, ReplicaID: "r2", Epoch: 2, EndpointVersion: 1, DataAddr: "d2", CtrlAddr: "c2", Incarnation: "r2-a"}
|
||||
reader := newFakeBasisReader()
|
||||
reader.Set("v1", "r2", line)
|
||||
ctrl := NewTopologyController(TopologyControllerConfig{PrimaryBootGrace: testBootGrace}, reader)
|
||||
r2 := candidate("r2", "s2", "d2", "c2", 20)
|
||||
r2.Incarnation, r2.ObservedAt = "r2-b", g.now
|
||||
r3 := candidate("r3", "s3", "d3", "c3", 10)
|
||||
r3.Incarnation, r3.ObservedAt = "r3-a", g.now
|
||||
snap := ClusterSnapshot{CollectedRevision: 1,
|
||||
Servers: []ServerObservation{{ServerID: "s1", Reachable: false}, {ServerID: "s2", Reachable: true, Eligible: true}, {ServerID: "s3", Reachable: true, Eligible: true}},
|
||||
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, dead, r2, r3)}}
|
||||
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ask = nextAskOrFail(t, ctrl)
|
||||
if ask.Intent != IntentRefreshEndpoint || ask.ReplicaID != "r2" || ask.Incarnation != "r2-b" {
|
||||
t.Fatalf("the promoted target restarted: %+v; want a refresh of r2 for r2-b, not another promotion", ask)
|
||||
}
|
||||
}
|
||||
|
||||
// Cell (LOCAL mode): re-issuing a workspace volume's line for a restarted
|
||||
// primary moves only its endpoint version. The workspace record (moves,
|
||||
// lease, revocation) is the one the line already had, and the holder keeps
|
||||
// renewing at its epoch: neither the lease nor the layout's HEAD and claim
|
||||
// (which name the epoch, never the endpoint version) are touched.
|
||||
func TestWorkspaceRestartReissueTouchesOnlyTheEndpointVersion(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
disk, _ := newTempStore(t)
|
||||
now := time.Unix(1000, 0)
|
||||
p := NewPublisher(nil, WithStore(disk), WithWorkspaceLeaseConfig(time.Second, func() time.Time { return now }))
|
||||
if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind, Incarnation: "p1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "v", "r", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.mu.Lock()
|
||||
before := cloneWorkspace(p.workspace["v"])
|
||||
p.mu.Unlock()
|
||||
if before == nil {
|
||||
t.Fatal("fixture: the volume is not enrolled")
|
||||
}
|
||||
if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentRefreshEndpoint, Incarnation: "p2"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, _ := p.LastPublished("v", "r"); got.Epoch != 1 || got.EndpointVersion != 2 || got.Incarnation != "p2" {
|
||||
t.Fatalf("re-issued workspace line %+v; want epoch 1, EV 2, p2", got)
|
||||
}
|
||||
p.mu.Lock()
|
||||
after := cloneWorkspace(p.workspace["v"])
|
||||
p.mu.Unlock()
|
||||
if !reflect.DeepEqual(before, after) {
|
||||
t.Fatalf("the re-issue changed the workspace record:\nbefore %+v\nafter %+v", before, after)
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "v", "r", 1); err != nil {
|
||||
t.Fatalf("the holder no longer renews at its epoch: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -1177,6 +1177,7 @@ func (s *services) assignmentFact(info adapter.AssignmentInfo) *control.Assignme
|
||||
EvidenceDurableLsn: info.Primary.DurableLSN,
|
||||
EvidenceEpoch: info.Primary.DataEpoch,
|
||||
EvidenceFirstLsn: info.Primary.DataFirstLSN,
|
||||
LineIncarnation: info.Incarnation,
|
||||
}
|
||||
if info.Primary.StoreID != ([16]byte{}) {
|
||||
id := info.Primary.StoreID
|
||||
|
||||
@@ -880,7 +880,9 @@ func (h *Host) storeAttestation() *control.StoreAttestation {
|
||||
return att
|
||||
}
|
||||
|
||||
// newIncarnation returns a random process incarnation id.
|
||||
// newIncarnation returns a random process incarnation id. The master compares
|
||||
// incarnations only for equality (a restarted process), never for order, so
|
||||
// the clock fallback when the random source fails is enough.
|
||||
func newIncarnation() string {
|
||||
var b [8]byte
|
||||
if _, err := rand.Read(b[:]); err != nil {
|
||||
@@ -1127,6 +1129,17 @@ func (h *Host) applyFact(fact *control.AssignmentFact) {
|
||||
}
|
||||
}
|
||||
|
||||
// A line issued for another process of this replica is the dead
|
||||
// process's: its sessions (endpoint version, session id) are the ones
|
||||
// each replica still holds, and a session this process opened on it
|
||||
// could equal one of them. Nothing is adopted until the master
|
||||
// re-issues the line for this process (a new endpoint version).
|
||||
if inc := fact.GetLineIncarnation(); inc != "" && inc != h.incarnation {
|
||||
h.log.Printf("blockvolume: volume %s line epoch=%d EV=%d was issued for process %s, this is %s: NOT adopting until it is re-issued",
|
||||
h.cfg.VolumeID, fact.Epoch, fact.EndpointVersion, inc, h.incarnation)
|
||||
return
|
||||
}
|
||||
|
||||
// The target's own store must still show what the master probed before
|
||||
// it adopts the role (nothing is installed yet, so a refusal has no
|
||||
// effect to undo).
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
)
|
||||
|
||||
// A restarted primary process holds the dead process's line until the
|
||||
// master re-issues it: that line's sessions (endpoint version, session id)
|
||||
// are the ones each replica still holds, and a session opened on it could
|
||||
// equal one of them. So the process adopts nothing on it (no replica
|
||||
// session, no role) and adopts the re-issued line for itself.
|
||||
func TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted(t *testing.T) {
|
||||
rec := &orderingRecorder{}
|
||||
h, a, r := newStubbedHost(t, "vol1", "r1", rec)
|
||||
h.incarnation = "p2"
|
||||
fact := func(ev uint64, incarnation string) *control.AssignmentFact {
|
||||
return &control.AssignmentFact{
|
||||
VolumeId: "vol1", ReplicaId: "r1", Epoch: 5, EndpointVersion: ev,
|
||||
DataAddr: "127.0.0.1:1000", CtrlAddr: "127.0.0.1:1001",
|
||||
Peers: []*control.ReplicaDescriptor{{ReplicaId: "r2", Epoch: 5, EndpointVersion: ev, DataAddr: "127.0.0.1:2000", CtrlAddr: "127.0.0.1:2001"}},
|
||||
PeerSetGeneration: 5<<32 | ev,
|
||||
LineIncarnation: incarnation,
|
||||
}
|
||||
}
|
||||
h.applyFixtureFact(fact(1, "p1"))
|
||||
if r.callCount.Load() != 0 || a.callCount.Load() != 0 {
|
||||
t.Fatalf("the dead process's line was adopted: replica sets %d, assignments %d", r.callCount.Load(), a.callCount.Load())
|
||||
}
|
||||
h.applyFixtureFact(fact(2, "p2"))
|
||||
if r.callCount.Load() != 1 || a.callCount.Load() != 1 || a.lastInfo.EndpointVersion != 2 {
|
||||
t.Fatalf("the line re-issued for this process: replica sets %d, assignments %d (EV %d); want both at EV 2", r.callCount.Load(), a.callCount.Load(), a.lastInfo.EndpointVersion)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package replication
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/adapter"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
"github.com/seaweedfs/seaweed-block/core/transport"
|
||||
)
|
||||
|
||||
// A primary process restarted at the same epoch and address (its line kept
|
||||
// through the boot grace) starts a new session order at 1, while each
|
||||
// replica still holds the dead process's latest session. The master
|
||||
// re-issues the line for the new process at a new endpoint version, so the
|
||||
// new process's live ship and its catch-up both outrank the held session
|
||||
// and are admitted. At the old endpoint version both are refused as older.
|
||||
func TestRestartedPrimaryAtTheSameEpochIsAdmitted(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
replica := storage.NewBlockStore(64, 4096)
|
||||
floor := filepath.Join(dir, "v1.floor")
|
||||
if err := transport.InitReplicaFloor(floor, "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
listener, err := transport.NewReplicaListenerWithFloorAndApplyHook("127.0.0.1:0", replica, "v1", floor, NewReplicaApplyGate(replica))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := listener.AdmitAsReplica(1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
listener.Serve()
|
||||
t.Cleanup(listener.Stop)
|
||||
target := targetFor("r1", listener.Addr(), 1, 1)
|
||||
primary := storage.NewBlockStore(64, 4096)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
write := func(v *ReplicationVolume, lba uint32, fill byte) {
|
||||
t.Helper()
|
||||
data := bytes.Repeat([]byte{fill}, 4096)
|
||||
lsn, err := primary.Write(lba, data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := v.Observe(ctx, lba, lsn, data); err != nil {
|
||||
t.Fatalf("ship LSN %d: %v", lsn, err)
|
||||
}
|
||||
if err := v.Sync(ctx, lsn); err != nil {
|
||||
t.Fatalf("barrier at LSN %d: %v", lsn, err)
|
||||
}
|
||||
}
|
||||
|
||||
// The old process: its peer re-added a few times (each a live
|
||||
// session), then it dies.
|
||||
old := NewReplicationVolume("v1", primary)
|
||||
for gen := uint64(1); gen <= 6; gen += 2 {
|
||||
if err := old.UpdateReplicaSet(gen, []ReplicaTarget{target}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write(old, uint32(gen), byte(gen))
|
||||
if err := old.UpdateReplicaSet(gen+1, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := old.UpdateReplicaSet(7, []ReplicaTarget{target}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write(old, 7, 7)
|
||||
_ = old.Close()
|
||||
|
||||
// The restarted process, on its re-issued line: same epoch and
|
||||
// address, the next endpoint version.
|
||||
restarted := NewReplicationVolume("v1", primary)
|
||||
t.Cleanup(func() { _ = restarted.Close() })
|
||||
reissued := targetFor("r1", listener.Addr(), 1, 2)
|
||||
if err := restarted.UpdateReplicaSet(1, []ReplicaTarget{reissued}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
write(restarted, 8, 8)
|
||||
if got, err := replica.Read(8); err != nil || !bytes.Equal(got, bytes.Repeat([]byte{8}, 4096)) {
|
||||
t.Fatalf("the restarted primary's live ship did not land (err %v): refused as an older session", err)
|
||||
}
|
||||
|
||||
exec := restarted.peers["r1"].Executor()
|
||||
closed := make(chan adapter.SessionCloseResult, 1)
|
||||
exec.SetOnSessionStart(func(adapter.SessionStartResult) {})
|
||||
exec.SetOnSessionClose(func(r adapter.SessionCloseResult) { closed <- r })
|
||||
end, _ := replica.Sync()
|
||||
_, _, head := primary.Boundaries()
|
||||
if err := exec.StartCatchUp("r1", exec.SessionIDs().Next(), 1, 2, end+1, head); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case r := <-closed:
|
||||
if !r.Success {
|
||||
t.Fatalf("the restarted primary's catch-up was refused: %+v", r)
|
||||
}
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("the catch-up never closed")
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -318,6 +318,11 @@ message AssignmentFact {
|
||||
uint32 replica_stores_awaited = 15;
|
||||
// The number of initial replicas (the N of "n of N" in its status).
|
||||
uint32 replica_stores_initial = 16;
|
||||
// The primary process this line was issued for (its reported
|
||||
// incarnation; "" = not recorded). A primary whose own incarnation is
|
||||
// another one is a restarted process: it opens no replica session on
|
||||
// this line, whose sessions belong to the dead process.
|
||||
string line_incarnation = 17;
|
||||
}
|
||||
|
||||
// PrimaryKind is how a line made its primary the primary.
|
||||
|
||||
@@ -694,6 +694,7 @@ Notes:
|
||||
| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/frontend/chunkstore/layout/start.go` `Start`, `core/frontend/chunkstore/layout/claim.go` `Claim`; superseded exit covered by #409; `core/host/master/workspace_binding.go` `workspaceLineOwner`, `workspaceSourceHost`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend); `core/authority/snapshot_builder.go` `expectOwnerForLine` (a moved line's replica facts and endpoint refreshes only from its owner, #425) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestWorkspaceLineOwnerIssuedAndHistorical` (`core/host/master/workspace_line_owner_test.go`), `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestAssignmentFactKeepsCapturedMoveOwnerWithoutReadableJournal` (`core/host/master/assignment_fact_owner_test.go`), `TestAssignmentOwnerReservedAndIssuedCapture` (`core/authority/assignment_owner_test.go`), `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: with mutual TLS on, a node may act only for the server id bound to its certificate (`TERM-CALLER-001`; `auth.RequireNode` in `ReportHeartbeat`, `SubscribeAssignments`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`, `QueryVolumeStatus`; `TestNodeActsOnlyForItsOwnServerID`, `core/host/master/auth_red_test.go`), and the registered-host check stays beside it (no NAT or proxy between volume and master in OSS); in development mode (plaintext on loopback, no role file) there is no authentication; `TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner` (`core/authority/line_owner_snapshot_test.go`); `TestProcedureForcedMoveWithTheOldHostReturning` (`cmd/blockvolume/procedure_gate_integration_test.go`, tags subprocess chunkstore_integration: every forced-epoch line carries the new owner's endpoints) | `WorkspaceRegrant` `NoForeignAdoption`, `TargetNotFencLine truncated
|
||||
| `INV-AUTH-CALLER-ROLE-001` | With mutual TLS on, every blockmaster gRPC call (unary, and before every stream send) is decided by the caller's certificate and the current role file: an unknown caller is refused UNAUTHENTICATED, a role its method's rule does not admit PERMISSION_DENIED, a method without a rule always. | AUTHORITY: control API callers (people, tools, nodes) | `core/auth/identity.go` `Authenticator.PeerIdentity`, `Authenticator.Reload`; `core/auth/authorize.go` `Rule.Allows`, `UnaryInterceptor`, `StreamInterceptor`, `RequireNode`, `RequireRole`; `core/host/master/authz.go` `masterRules`, `serverAuth`; `core/rpc/link/tls.go` `ServerCredentials`, `ClientCredentials`; `cmd/blockmaster/auth.go` `authFlags.validate`, `authFlags.build` | `TestPeerIdentity`, `TestRoleFileReload` (`core/auth/identity_test.go`); `TestRuleAllows`, `TestRequireNodeAndRole`, `TestUnaryInterceptor`, `TestStreamEndsAtTheReloadThatRevokesItsCaller` (`core/auth/authorize_test.go`); `TestMasterAuthorizationTableCoversEveryMethod` (`core/host/master/authz_test.go`); `TestForcedMoveNeedsAnAdmin`, `TestNodeActsOnlyForItsOwnServerID` (`core/host/master/auth_red_test.go`); `TestMasterLinkMutualTLS` (`core/rpc/link/tls_test.go`); `TestAuthFlags` (`cmd/blockmaster/auth_flags_test.go`); `TestMasterTLSFlags` (`cmd/blockvolume/master_tls_test.go`). Also: a mutating operator or admin method writes its audit attempt before it runs or is refused as audit unavailable (`Rule.Strict`; `TestMasterOperatorMethodsAreStrict` (inverted: a new operator or admin method fails unless strict or named with its reason), `core/host/master/authz_test.go`; `TestStrictCallsNeedTheirAttemptLine`, `core/auth/strict_audit_test.go`), node calls never wait on the audit log; a reload that removes a caller, or changes its role so the method's rule no longer admits it, ends its open streams at the reload; a forced move needs an admin; plaintext listens only on loopback without a role file (development mode). Limits: the audit log records outcomes and decides nothing; the volume process's own HTTP routes stay loopback-only and unauthenticated. | `AuthLease` (exhaustive run pending) | 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`) | `ControlPlane` `UniqueEpoch` | 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. | M1 authority (RefreshEndpoint) | `core/authority/authority.go` `apply`; `core/authority/controller.go` `endpointStale`; `core/host/volume/host.go` `applyFact` | `TestPublisher_RestartedPrimaryGetsANewEndpointVersion`, `TestTopologyController_RestartedPrimaryAtTheSameAddressIsReissued` (`core/authority/restart_endpoint_version_test.go`); `TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted` (`core/host/volume/line_incarnation_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 |
|
||||
| `INV-AUTH-UNCERTAIN-001` | A failed authority write for a workspace volume, a lease extension included, latches uncertainty until a restart reloads the store: later authority changes and new or extended grants for that volume are refused. See M2 any (workspace) → Uncertain and Uncertain → Uncertain (move answer). | M2 any (workspace) → Uncertain; Uncertain → Uncertain (move answer) | `core/authority/authority.go` `applyWithWorkspaceMove`; `core/authority/workspace.go` `persistWorkspaceLocked`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease`; `core/authority/workspace.go` `WorkspaceMoveOutcomeError`, `MoveWorkspace`; `core/host/master/workspace_service.go` `MoveWorkspace` | `TestWorkspaceAmbiguousExtensionLatchesUncertainty` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceUncertaintyPrecedesRequestRefusal` (`core/authority/workspace_outcome_uncertain_test.go`), `TestWorkspaceMoveUnknownPrecedesAdmissionRefusals` (`core/host/master/workspace_uncertain_precedence_test.go`), `TestWorkspaceUncertainIssueWriteIsTyped` (`core/authority/workspace_outcome_uncertain_test.go`) | `ControlPlane` `UniqueEpoch`; `WorkspaceMoveOutcome` `NoFalseRefusal`, `CallerEndTyped`, `UncertainReplyClass` | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user