mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
docs: Part T binds shared terms to one deciding function each
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ea276b450a
commit
6520134446
1 file changed
+33
@@ -30,6 +30,7 @@ The design is described in three documents, and this one collects their machines
|
||||
- [Part C. Change rules](#part-c-change-rules)
|
||||
- [Part D. Wait ownership](#part-d-wait-ownership)
|
||||
- [Part E. Quantities](#part-e-quantities)
|
||||
- [Part T. Terms bound to code](#part-t-terms-bound-to-code)
|
||||
|
||||
---
|
||||
|
||||
@@ -956,3 +957,35 @@ Frozen estimate reporting: a tail above the existing 60 s estimator ceiling repo
|
||||
| Quantity | Unit | Cap | Enforced at (producer) | Drained | Outcome at the cap |
|
||||
|---|---|---|---|---|---|
|
||||
| COW side-file spill per cut | bytes | min(`COWSpillLimit` (default 1 GiB, or the host limit's COW bytes), free space on `--durable-root` / 2 - 1 GiB), at least 0; the free space is read once per cut and that cap bounds both staging and the copy window; off Linux, the configured cap. Shown per cut in the layer stats (`COWSpillCap`, `COWSpillCapReason`: `no_room_to_cut` when the free space is within the reserve, `free_space_unreadable` when the read fails) | the saver: `core/storage/chunk_cut_cow.go` `readCutSpill`, the save's cap check | at the cut's end (the side file is removed on publish, abort or close) | that cut aborts (retryable), counted as `cow_capacity`, or as `no_room_to_cut` / `free_space_unreadable` when the free space made the cap 0; the guest write completes and nothing partial is published |
|
||||
|
||||
## Part T. Terms bound to code
|
||||
|
||||
Some facts are read by many parts of the code: who the holder is, whether the lease is valid, whether the volume may serve. Each such fact is a term. For each term this part lists the fields that carry it, the one function that decides it on each side, and the role that owns it. **A second derivation of a term is a defect.** Code that needs a term calls its deciding function, or a function that only wraps that call. It never compares the term's fields again itself. Known second derivations are listed in each row together with the pull request that removes them, or "open".
|
||||
|
||||
A reviewer applies the rule to every pull request:
|
||||
|
||||
1. If the diff reads or compares a field listed in a row anywhere other than that row's deciding function, it must call the deciding function instead. Otherwise it changes the row in the same pull request, and the description says why.
|
||||
2. A pull request that removes a listed second derivation also deletes it from the row. A pull request that adds a new one is refused, unless it adds the new derivation to the row as open, with a reason.
|
||||
3. Renaming, moving or splitting a deciding function updates its row in the same pull request.
|
||||
|
||||
A row that names a function existing only on an open pull request says so ("on #N"). The qualifier is dropped when that pull request merges. Code references name a file and a function, as in the rest of this document. A checker will later verify that every deciding function named here exists on `main`.
|
||||
|
||||
10 rows for 5 terms. They name 13 deciding functions: 10 on `main` and 3 only on open pull requests (2 on #411, 1 on #409). One row (`TERM-STOP-STALE-ROOT-001`) has no named function yet.
|
||||
|
||||
| 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`. 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 computes the line's owner server twice: `holderMatches` reads `PublishedLine.IssuedHost` and falls back to `placementSourceHost`, while the fact's `server_id` and the move source come from `Host.workspaceSourceHost` (the move journal first, then `placementSourceHost`): open. `workspaceHeadAdmits` compares the HEAD holder, built from the volume's `--server-id` flag, with the registry server id, and nothing checks that the two are the same string: open. `DurableProvider.chunkHolder` (`core/frontend/durable/provider_seal_replay.go`) falls back to the replica id alone when no holder is configured: open. | 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`. `StorageBackend.gate` is the per-I/O AND of the two sides. | `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's `backendAdmitsIO` reads only `VolumeStatus.Operational`, once, and not the guarded projection: open (it should read the one AND). 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 |
|
||||
| `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host |
|
||||
| `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup leaves the lease renewing and the process running: open. Only a refused startup claim exits, with 78, on #409. | chunk layer |
|
||||
| `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host |
|
||||
| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) |
|
||||
| `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host |
|
||||
| `TERM-ONE-PROCESS-001` One live process per holder | At most one blockvolume process serves a holder at a time. Today a second process is refused only when it opens the same store file. A local-root nonce in the holder identity is to close the other cases (pending). | The store file `<--durable-root>/<volume id>.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); its exclusive OS file lock; the HEAD `Holder` | Volume: `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the lock's limit: it covers one file. A second process is not refused when it uses another `--durable-root`, runs on another host with the same server id, or runs on a copied root. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open, pending the local-root nonce. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine |
|
||||
|
||||
Notes:
|
||||
|
||||
- `TERM-SERVING-001` and `TERM-STOP-*`: in this release a workspace primary that can no longer serve should stop, not linger. Today `TERM-STOP-HEAD-FENCED-001` and `TERM-STOP-STALE-ROOT-001` leave the process up and its lease renewing. A forced move then waits for that lease. The open entries in those rows track this.
|
||||
- `TERM-HOLDER-001`: supporting replicas (RF greater than 1) are not holders, and their replica-keyed checks (`AdapterProjectionView.supportingReplicaReady`) are outside this row.
|
||||
Reference in new issue
Block a user