mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
blockvolume: firstAdmitted reports its own completion; the exit diagram carries the runtime HEAD fence
The stop test now observes the worker's return on its own channel with bounded joins on both paths (a re-check that ignores the stop fails in 12 s); agent-workspace-design.md's supervisor diagram adds Serving -> Exit78 on a runtime HEAD fence (head_fenced), independent of the lease. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50d6d92845
commit
10ce25ee9c
4 files changed
+51
-16
No files matched your search
@@ -35,7 +35,8 @@ type servingBackend interface {
|
||||
// open, as before: it never makes the claim a workspace primary waits for.
|
||||
func frontendStartSignal(f flags, b servingBackend, stop <-chan struct{}) <-chan struct{} {
|
||||
if f.workspaceLease && f.durableImpl == "walstore-chunk" {
|
||||
return firstAdmitted(stop, b.FirstServing(), b.AdmitsIO)
|
||||
out, _ := firstAdmitted(stop, b.FirstServing(), b.AdmitsIO)
|
||||
return out
|
||||
}
|
||||
return b.FirstServing()
|
||||
}
|
||||
@@ -45,12 +46,14 @@ func frontendStartSignal(f flags, b servingBackend, stop <-chan struct{}) <-chan
|
||||
// backend has no projection-change signal.
|
||||
const admitRecheck = 50 * time.Millisecond
|
||||
|
||||
// firstAdmitted is closed once first has closed (the backend first admitted
|
||||
// I/O) and admits() then passes; it re-checks every admitRecheck until then,
|
||||
// and ends without closing when stop closes.
|
||||
func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() error) <-chan struct{} {
|
||||
out := make(chan struct{})
|
||||
// firstAdmitted's out is closed once first has closed (the backend first
|
||||
// admitted I/O) and admits() then passes; it re-checks every admitRecheck
|
||||
// until then, and ends without closing out when stop closes. done is closed
|
||||
// when its goroutine has returned, on either path.
|
||||
func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() error) (out, done <-chan struct{}) {
|
||||
o, d := make(chan struct{}), make(chan struct{})
|
||||
go func() {
|
||||
defer close(d)
|
||||
select {
|
||||
case <-first:
|
||||
case <-stop:
|
||||
@@ -65,9 +68,9 @@ func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() er
|
||||
return
|
||||
}
|
||||
}
|
||||
close(out)
|
||||
close(o)
|
||||
}()
|
||||
return out
|
||||
return o, d
|
||||
}
|
||||
|
||||
func awaitFrontendStart(serving <-chan struct{}, stopWait <-chan workspaceStopWait) (stopped *workspaceStopWait, start bool) {
|
||||
|
||||
@@ -50,13 +50,41 @@ func TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO(t *testing.T) {
|
||||
t.Fatal("did not start after AdmitsIO passed")
|
||||
}
|
||||
|
||||
stop2 := make(chan struct{})
|
||||
b2 := &servingStub{first: make(chan struct{})}
|
||||
close(b2.first)
|
||||
sig2 := frontendStartSignal(f, b2, stop2)
|
||||
close(stop2)
|
||||
if closedWithin(sig2, 4*admitRecheck) {
|
||||
t.Fatal("a stopped wait started the targets")
|
||||
}
|
||||
|
||||
// A stop ends firstAdmitted's worker without starting the targets, both
|
||||
// while it waits for the first admitted I/O and while it re-checks AdmitsIO:
|
||||
// its completion is observed on its own channel, and every join is bounded.
|
||||
func TestFirstAdmittedStopEndsTheWorker(t *testing.T) {
|
||||
for _, served := range []bool{false, true} {
|
||||
stop := make(chan struct{})
|
||||
b := &servingStub{first: make(chan struct{})}
|
||||
if served {
|
||||
close(b.first) // re-checking AdmitsIO, which keeps refusing
|
||||
}
|
||||
out, done := firstAdmitted(stop, b.FirstServing(), b.AdmitsIO)
|
||||
stopped := false
|
||||
t.Cleanup(func() {
|
||||
if !stopped {
|
||||
close(stop)
|
||||
}
|
||||
if !closedWithin(done, 5*time.Second) {
|
||||
t.Errorf("served=%v: the worker did not return within 5s of its stop (cleanup)", served)
|
||||
}
|
||||
})
|
||||
if closedWithin(done, 2*admitRecheck) {
|
||||
t.Fatalf("served=%v: the worker returned before any stop", served)
|
||||
}
|
||||
close(stop)
|
||||
stopped = true
|
||||
if !closedWithin(done, 5*time.Second) {
|
||||
t.Fatalf("served=%v: the worker did not return within 5s of its stop", served)
|
||||
}
|
||||
select {
|
||||
case <-out:
|
||||
t.Fatalf("served=%v: a stopped wait started the targets", served)
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -489,6 +489,9 @@ RestartSec=5s. A newer master fact naming another replica or a refused claim pro
|
||||
HEAD holder permits exit 78;
|
||||
RestartPreventExitStatus=78 suppresses automatic restarts until an operator
|
||||
explicitly starts the unit. A higher epoch for the same replica retries.
|
||||
A HEAD fence after the target listens (the attached chunk layer finds HEAD owned
|
||||
by another publisher while the lease may still be valid) is independent of the
|
||||
lease and exits 78 `head_fenced` (INV-FE-FENCE-EXIT-001).
|
||||
An ACKed planned revocation and a signal stop retain their normal exit status.
|
||||
Sealed same-epoch recovery stays non-serving for seal replay after assignment.
|
||||
Local-root, WAL-corruption and I/O diagnostics retain their existing wait.
|
||||
@@ -503,6 +506,7 @@ stateDiagram-v2
|
||||
Serving --> Exit75: lease fence
|
||||
AwaitingAssignment --> Exit78: newer other-replica fact or exact foreign-holder HEAD claim proof
|
||||
Serving --> Exit78: lease fence and newer other-replica fact
|
||||
Serving --> Exit78: runtime HEAD fence (another publication owner), head_fenced
|
||||
Exit75 --> AwaitingAssignment: supervisor starts new process
|
||||
Exit78 --> AwaitingAssignment: explicit operator start
|
||||
AwaitingAssignment --> SealedReplay: assigned same-epoch sealed HEAD
|
||||
|
||||
@@ -465,7 +465,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE |
|
||||
| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE |
|
||||
| `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens ends the process within detection plus the 5 s cleanup bound: a lease expiry at the guard's own deadline, a HEAD fence within 50 ms. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE |
|
||||
| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/frontend/durable/storage_adapter.go` `AdmitsIO` (the one "may serve" function, the I/O gate: backend admits AND guarded projection names this lineage; V1-SPEC r2.39); `core/host/volume/status_server.go` `statusProjection` (`FrontendPrimaryReady` from `AdmitsIO`; `NotReadyReason=lease_not_held` first); `cmd/blockvolume/frontend_gate.go` `frontendStartSignal` / `awaitFrontendStart` (a workspace primary's frontends start once `AdmitsIO` passes; non-chunk and supporting replicas start after open as before); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); `TestStorageBackend_AdmitsIOIsTheIOGate` (`core/frontend/durable/admits_io_test.go`); `TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO`, `TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore` (`cmd/blockvolume/frontend_start_signal_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE |
|
||||
| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/frontend/durable/storage_adapter.go` `AdmitsIO` (the one "may serve" function, the I/O gate: backend admits AND guarded projection names this lineage; V1-SPEC r2.39); `core/host/volume/status_server.go` `statusProjection` (`FrontendPrimaryReady` from `AdmitsIO`; `NotReadyReason=lease_not_held` first); `cmd/blockvolume/frontend_gate.go` `frontendStartSignal` / `awaitFrontendStart` (a workspace primary's frontends start once `AdmitsIO` passes; non-chunk and supporting replicas start after open as before); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); `TestStorageBackend_AdmitsIOIsTheIOGate` (`core/frontend/durable/admits_io_test.go`); `TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO`, `TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore`, `TestFirstAdmittedStopEndsTheWorker` (`cmd/blockvolume/frontend_start_signal_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE |
|
||||
| `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE |
|
||||
| `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE |
|
||||
| `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user