fix: one owner decision (PublishedLine.Owner); a moved line with an unknown owner takes facts from no server

Design review of #429 (V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001, TERM-HOLDER-001):
- PublishedLine.Owner is the single owner decision (move-named server; move-named but
  unknown; not from a move), called by Host.workspaceLineOwner and expectOwnerForLine.
- A move-minted line whose owner is unknown binds its replica to no server: no health,
  endpoints or refresh from anyone (control: the placement server's fresh report changes
  nothing). Only a line no move minted keeps the accepted topology.
- var _ lineOwnerReader = (*Publisher)(nil): dropping the method is a build error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-22 06:55:01 -08:00
1 parent 38732f5e88
commit 79d5d9f798
5 files changed
+60 -10

No files matched your search

@@ -42,6 +42,14 @@ func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) {
if !ok || r1.ServerID != "s2" || r1.DataAddr != "owner-s2:1" || r1.CtrlAddr != "owner-s2:2" {
t.Fatalf("line replica candidate %+v ok=%v, want the owner s2 at owner-s2:1/2 (never the old host s1)", r1, ok)
}
// a move minted the line but its owner is unknown: NO server supplies the replica's facts, so the returning
// placement server's fresh report changes nothing (no endpoint change, hence no refresh)
unknown := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2, OwnerFromMove: true}}}
if v, ok := findSupported(BuildSnapshot(store.Snapshot(), topo, unknown), "v1"); ok {
if r1, _ := candidateByReplica(v, "r1"); r1.ServerID == "s1" || r1.DataAddr == "old-s1:1" || (r1.DataAddr != "" && r1.DataAddr != "owner-s2:1") {
t.Fatalf("unknown owner: candidate %+v takes the placement server's report (want no server's facts)", r1)
}
}
// without a move-named owner the accepted topology stands (control)
plain := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2}}}
v, _ = findSupported(BuildSnapshot(store.Snapshot(), topo, plain), "v1")
@@ -49,3 +57,21 @@ func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) {
t.Fatalf("control: no move-named owner, candidate %+v, want the topology's s1", r1)
}
}
// TERM-HOLDER-001's single owner decision: the three outcomes of PublishedLine.Owner.
func TestPublishedLineOwnerOutcomes(t *testing.T) {
for _, c := range []struct {
pl PublishedLine
server string
fromMove bool
}{
{PublishedLine{IssuedHost: "s2", OwnerFromMove: true}, "s2", true},
{PublishedLine{IssuedHost: "s2"}, "s2", true},
{PublishedLine{OwnerFromMove: true}, "", true},
{PublishedLine{}, "", false},
} {
if server, fromMove := c.pl.Owner(); server != c.server || fromMove != c.fromMove {
t.Fatalf("%+v.Owner() = %q, %v; want %q, %v", c.pl, server, fromMove, c.server, c.fromMove)
}
}
}
@@ -482,24 +482,30 @@ type lineOwnerReader interface {
PublishedAuthorityLine(volume string) (PublishedLine, bool)
}
// expectOwnerForLine binds the expected slot of the line's replica to the line's owner when a move named it (#425,
// V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): a line carries its owner and that owner's endpoints, so its replica's
// facts (health, endpoints, and any endpoint refresh) come only from that server, never from the placement or
// topology server it was moved away from. Without a move-named owner the expected topology stands unchanged.
// expectOwnerForLine binds the expected slot of the line's replica to the line's owner (PublishedLine.Owner) when a
// move minted the line (#425, V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): a line carries its owner and that owner's
// endpoints, so its replica's facts (health, endpoints, and any endpoint refresh) come only from that server, never
// from the placement or topology server it was moved away from. A move-minted line whose owner is unknown is bound to
// NO server (no fact from anyone, so no refresh) until the owner is known. Only a line no move minted keeps the
// accepted topology.
func expectOwnerForLine(expected VolumeExpected, volumeID string, line AuthorityBasis, reader AuthorityBasisReader) VolumeExpected {
r, ok := reader.(lineOwnerReader)
if !ok {
return expected
}
pl, ok := r.PublishedAuthorityLine(volumeID)
if !ok || pl.ReplicaID != line.ReplicaID || pl.Epoch != line.Epoch || !(pl.OwnerFromMove || pl.IssuedHost != "") || pl.IssuedHost == "" {
if !ok || pl.ReplicaID != line.ReplicaID || pl.Epoch != line.Epoch {
return expected
}
server, fromMove := pl.Owner()
if !fromMove {
return expected
}
out := VolumeExpected{VolumeID: expected.VolumeID, Slots: make([]ExpectedSlot, len(expected.Slots))}
copy(out.Slots, expected.Slots)
for i := range out.Slots {
if out.Slots[i].ReplicaID == line.ReplicaID {
out.Slots[i].ServerID = pl.IssuedHost
out.Slots[i].ServerID = server // "" for an unknown owner: no server supplies this replica's facts
}
}
return out
@@ -155,6 +155,22 @@ type PublishedLine struct {
OwnerFromMove bool
}
// Owner is TERM-HOLDER-001's single owner decision for a line (INV-AUTH-HOLDER-IDENTITY-001), shared by the master's
// workspaceLineOwner and the snapshot builder. Three outcomes:
// - fromMove, server != "": a move minted the line on server;
// - fromMove, server == "": a move minted it but its owner is unknown: no server may supply its facts;
// - !fromMove: no move minted it; the caller uses placement / the accepted topology.
func (pl PublishedLine) Owner() (server string, fromMove bool) {
if pl.OwnerFromMove || pl.IssuedHost != "" {
return pl.IssuedHost, true
}
return "", false
}
// The snapshot builder binds a moved line's replica to its owner through this method; the production reader must
// provide it (a refactor dropping it is a build error, not a silent return to placement).
var _ lineOwnerReader = (*Publisher)(nil)
// PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity
// checks on renewal must not wait for p.mu, which spans authority store I/O
// (INV-LEASE-VIEW-001, INV-WS-RENEW-NONBLOCKING-001).
@@ -78,8 +78,8 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string
// lines need the move journal. Endpoints never identify a server.
func (h *Host) workspaceLineOwner(current authority.PublishedLine, volume, replica string, epoch uint64) string {
if current.ReplicaID == replica && current.Epoch == epoch {
if current.OwnerFromMove || current.IssuedHost != "" {
return current.IssuedHost
if server, fromMove := current.Owner(); fromMove { // the single owner decision (PublishedLine.Owner)
return server
}
return h.placementSourceHost(volume, replica)
}
+4 -2
View File
@@ -93,7 +93,9 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a
**Workspace lease and move, in blockmaster.**
TERM-HOLDER-001 uses one deciding function, `Host.workspaceLineOwner`. The
TERM-HOLDER-001 uses one owner decision, `PublishedLine.Owner` (core/authority),
called by `Host.workspaceLineOwner` and by the snapshot builder's `expectOwnerForLine`
(a moved line's replica facts come only from its owner, none for an unknown owner). The
stream supplies the PublishedLine captured in its AssignmentInfo; lease/ACK
checks supply the captured leaf view; move source uses a leaf snapshot wrapper.
`Publisher.captureAssignmentOwner` captures the moved owner under the publication
@@ -1019,7 +1021,7 @@ A row that names a function existing only on an open pull request says so ("on #
| Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role |
|---|---|---|---|---|---|
| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `<server id>/<replica id>` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) |
| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `<server id>/<replica id>` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines (through `PublishedLine.Owner`, which the snapshot builder's `expectOwnerForLine` also calls). The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) |
| `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) |
| `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host |
| `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host |