docs: add authority protocol and recovery deep dives

This commit is contained in:
pingqiu committed 2026-06-17 17:01:59 -07:00
1 parent ff0ef48c66
commit 5d4e5c7f4e
6 files changed
+472 -4

No files matched your search

+3 -3
View File
@@ -29,9 +29,9 @@ Coverage levels:
| ManagedVolume readiness | Shared ready/blocked/unknown model | Phase 22, 32, 35-36 | deep initial | add reason-code taxonomy |
| Node readiness / CSI evidence | Avoids false node-ready status | Phase 37 | linked | detailed live evidence diagram |
| SmartWAL dirty failure | Proves dirty storage evidence cannot become false Ready | Phase 34 | deep | add exact test log excerpts later |
| Authority / epoch / promotion | One-primary, fencing, restart authority persistence | Phases 13-18, 31, invariant ledger | linked | authority protocol deep dive |
| Returned-replica rebuild/reintegration | Next major storage lifecycle feature | recovery refs, roadmap | linked | readiness/gap analysis |
| iSCSI frontend / ALUA / multipath | Current default frontend and transparent failover path | iSCSI refs, Phase 17, 27, 37 | linked | ALUA path-state diagram |
| Authority / epoch / promotion | One-primary, fencing, restart authority persistence | Phases 13-18, 31, invariant ledger | deep initial | add code-level product-loop walkthrough |
| Returned-replica rebuild/reintegration | Next major storage lifecycle feature | recovery refs, roadmap | deep initial | add concrete future gate plan |
| iSCSI frontend / ALUA / multipath | Current default frontend and transparent failover path | iSCSI refs, Phase 17, 27, 37 | deep initial | add artifact examples |
| NVMe ANA parity | Planned protocol parity path | NVMe refs, roadmap | linked | future protocol page |
| TestOps runner and scenarios | Product evidence, not just tests | `testops/`, Phase 33-34 | deep initial | add runner action reference |
| Support bundle/replay/report/dashboard | Cold-reader diagnosis and support path | Phases 23-24, 28, 32, 36 | mapped | bundle structure diagram |
@@ -0,0 +1,155 @@
# Authority, Epoch, And Promotion
This page explains how Seaweed Block decides which replica is allowed to be
primary, why stale primaries must fail closed, and why promotion is more than
"pick another pod".
## Reader Orientation
In a block-storage system, authority answers:
```text
which replica is allowed to accept writes for this volume now?
```
You need this page before changing:
- blockmaster promotion logic,
- replica readiness/probe code,
- CSI publish-target selection,
- frontend stale-owner fencing,
- restart persistence of primary/epoch,
- returned-replica rebuild or failback.
## Domain Background
Distributed storage cannot allow two writable primaries for the same block
volume. Even a brief split can corrupt a filesystem because block clients assume
one coherent device.
Practical terms:
| Term | Meaning |
|---|---|
| primary | replica currently authorized to serve frontend writes |
| epoch | monotonic authority generation |
| endpoint version | frontend/publish target generation |
| stale primary | old primary that was valid in an earlier authority generation |
| promotion | changing authority to a new primary after evidence allows it |
| fencing | preventing old authority/session from accepting writes |
| durable frontier | write progress boundary a candidate must cover |
The industry pattern is the same whether the product is Ceph RBD, Longhorn,
Mayastor, or a custom block layer: authority must be explicit, monotonic, and
observable.
## Product Problem
Seaweed Block must support recovery and restart without letting old truth become
new truth:
```text
promotion to r2
-> restart control plane or kubelet
-> r1 must not resurrect as primary
-> r2/epoch/publish target remain authoritative
```
The hard part is that many signals are tempting but insufficient:
- pod Running,
- status endpoint reachable,
- heartbeat present,
- replica observed,
- local storage opened.
None of those alone prove authority.
## Methodology
Authority follows the method:
```text
facts: replica reachability, durable frontier, current assignment
constraints: one primary, monotonic epoch, candidate covers frontier
decision owner: blockmaster / authority path
execution: assignment publication and frontend projection
evidence: cluster evidence, Events, QA run summaries
```
CSI consumes authority. It does not choose a primary.
## State Machine
```mermaid
stateDiagram-v2
[*] --> PrimaryStable
PrimaryStable --> CandidateEvaluation: current primary fails or is unavailable
CandidateEvaluation --> Refused: no candidate covers frontier
CandidateEvaluation --> PromotionAllowed: candidate ready and frontier covered
PromotionAllowed --> AuthorityPublished: epoch/publish target updated
AuthorityPublished --> StalePrimaryFenced: old primary cannot ACK writes
StalePrimaryFenced --> PrimaryStable: new primary verified
Refused --> PrimaryStable: current primary recovers or evidence changes
```
## Key Invariants
From the invariant ledger:
| Invariant | Meaning |
|---|---|
| `INV-AUTH-ONE-PRIMARY-001` | after promotion, there is at most one current primary |
| `INV-FENCE-STALE-PRIMARY-001` | stale primary cannot ACK post-failure writes |
| `INV-PROMOTE-FRONTIER-001` | candidate must cover required durable frontier |
| `INV-CSI-CONSUMES-AUTHORITY-001` | CSI consumes publish target; it does not mint authority |
## Implementation Map
| Responsibility | Code area |
|---|---|
| product loop and promotion decision | `core/host/master/product_loop.go` |
| promotion probing | `core/host/master/promotion_probe.go` |
| observation snapshot | `core/host/master/observation_snapshot.go` |
| frontend projection bridge | `core/host/volume/projection_bridge.go` |
| durable frontend readiness | `core/frontend/durable/` |
| CSI publish target consumption | `core/csi` |
## Phase History
| Phase | Contribution |
|---|---|
| 13-18 | restart, reattach, mounted failover, node-loss survival foundations |
| 27/31 | RF3 promotion restart persistence: primary/epoch/publish target survive restart |
| 34 | dirty-failure gate forced positive primary readiness before Ready projection |
| 37 | live node/CSI blockers no longer mask authority-adjacent failure states |
| 41-44 | operation layer can now explain lifecycle safety without minting authority |
## QA Evidence
| Gate | What it proves |
|---|---|
| RF3 promotion restart persistence | promoted authority survives k3s restart |
| stale primary I/O probes | old primary cannot successfully serve stale writes |
| multi-volume restart/failover gates | authority does not mix across volumes |
| SmartWAL corruption gate | reachable process is not enough for Ready |
## Non-Claims
- No automatic failback yet.
- Returned-replica rebuild is not productized yet.
- CSI does not decide promotion.
- Operation-layer status does not create authority.
## Future Work
Returned-replica rebuild should reuse this exact model:
```text
returned replica observed
-> fenced from frontend
-> rebuild/catch-up evidence current
-> candidate transitions through visible states
-> only then placement/ACK eligibility can change
```
@@ -0,0 +1,157 @@
# iSCSI ALUA And Linux dm-multipath
This page explains the mounted transparent failover path based on iSCSI ALUA
and Linux dm-multipath.
## Reader Orientation
The normal Kubernetes CSI reattach path may require pod recreate. Stage 2
transparent failover asks a harder question:
```text
can the same mounted pod keep reading through a controlled primary failure?
```
The current proven protocol path is:
```text
iSCSI target portals + ALUA path states + Linux dm-multipath
```
## Domain Background
iSCSI exposes block devices over TCP. The host is the initiator; Seaweed Block
acts as the target.
ALUA means Asymmetric Logical Unit Access. It lets a target report path access
states such as optimized or non-optimized. Linux dm-multipath can combine
multiple paths to the same logical device and switch active path when one path
fails or becomes non-optimal.
Practical vocabulary:
| Term | Meaning |
|---|---|
| initiator | host side, e.g. Linux node running `iscsiadm` |
| target | Seaweed Block frontend accepting iSCSI |
| IQN | iSCSI target identity |
| portal | target address such as `ip:3260` |
| ALUA | path access-state reporting |
| RTPG | SCSI report target port groups command |
| dm-multipath | Linux device-mapper path aggregation |
| stale path | old primary path that must not accept writes after authority moves |
## Product Problem
Transparent mounted failover is stronger than CSI reattach:
```text
same pod UID
same mounted filesystem path
primary fails
host path switches
reader verifies data
no pod recreate
```
The hard part is proving that this was really multipath failover, not a hidden
pod restart or direct blockvolume read.
## Methodology
Required facts:
```text
same IQN across paths
multiple sessions/portals
dm-multipath map exists
ALUA state visible
authority moves to a valid candidate
old primary cannot ACK stale I/O
same pod verifies data after failure
```
Constraints:
- master chooses authority; ALUA does not elect primary,
- candidate must cover the durable frontier,
- host must see one multipath device, not unrelated `/dev/sdX` devices,
- every wait has a bounded timeout and blocker reason.
## State / Path Diagram
```mermaid
flowchart TD
A[Pod writes through mounted filesystem] --> B[Linux block device]
B --> C[dm-multipath map]
C --> D1[iSCSI path to r1]
C --> D2[iSCSI path to r2]
C --> D3[iSCSI path to r3]
D1 --> E[ALUA optimized primary]
D2 --> F[ALUA non-optimized candidate]
D3 --> G[ALUA non-optimized candidate]
E --> H{primary failure}
H --> I[blockmaster promotes candidate]
I --> J[ALUA/path state changes]
J --> K[dm-multipath active path switches]
K --> L[same pod verifies data]
```
## Implementation Map
| Responsibility | Code / evidence area |
|---|---|
| CSI stage multipath opt-in | `core/csi` Stage 2 multipath path |
| iSCSI frontend | frontend iSCSI code and target state |
| authority evidence | `core/host/master` cluster evidence |
| host path evidence | `sg_rtpg`, `multipath`, `iscsiadm` artifacts |
| report model | `core/ops` host-path projection |
| scenarios | `stage2-iscsi-alua-multipath-*`, mounted failover scenarios |
## Evidence Required
A valid transparent failover claim needs lines like:
```text
protocol=iscsi
multipath_enabled=true
path_count_before>=2
path_count_after>=1
before_primary_replica=<rN>
promoted_replica=<rM>
post_failure_primary_count=1
old_primary_stale_io_success_count=0
data_check_after_failover=mounted_workload_checksum_passed
pod_recreate_used=false
```
## Phase History
| Phase | Contribution |
|---|---|
| iSCSI P6/P8 | OS initiator, ALUA, MPIO compatibility evidence |
| Stage 2 / Phase 17 | transparent host failover contract |
| Multi-volume phases | per-volume ALUA/multipath isolation |
| Phase 37 D4/D5 | host prereq and loopback/cross-node blockers surfaced |
## Failure Classes
Transparent failover must fail closed with named blockers:
- `attach_timeout`,
- `iscsi_login_timeout`,
- `multipath_map_timeout`,
- `alua_state_unavailable`,
- `authority_promotion_timeout`,
- `path_switch_timeout`,
- `stale_primary_fence_timeout`,
- `post_failure_io_timeout`,
- `cleanup_timeout`.
## Non-Claims
- This is not a generic production HA claim.
- NVMe ANA parity is separate.
- Pod-recreate CSI reattach is a different, weaker path.
- ALUA path state does not create authority; it reflects authority.
@@ -0,0 +1,151 @@
# Returned Replica Rebuild Readiness
This page explains why returned-replica rebuild/reintegration is the natural
next major storage lifecycle feature, and why it should not be treated as
"already done" just because lower-level recovery pieces exist.
## Reader Orientation
A returned replica is a replica that was absent, stale, or behind, then comes
back after the volume has continued elsewhere. The product question is:
```text
when can that replica safely rejoin placement, ACK eligibility, or frontend use?
```
This is harder than detecting that a pod is Running.
## Domain Background
Distributed block systems need a rebuild or catch-up path for stale replicas.
Common industry concepts:
| Term | Meaning |
|---|---|
| catch-up | replica is behind but WAL window can bring it current |
| rebuild | replica is too far behind; base data plus WAL is needed |
| durable frontier | progress boundary the replica must cover |
| pin floor | WAL retention lower bound needed by active recovery |
| barrier | terminal evidence that a recovery stream closed safely |
| reintegration | allowing a recovered replica back into normal serving/ACK policy |
| failback | moving primary role back after recovery; a separate policy decision |
The older design notes describe this as:
```text
recover(a) != merely recover(a,b)
```
Meaning: enumerating data up to a target is not enough. The product must know
whether the replica is safe for the role being claimed.
## Product Problem
Seaweed Block already has important lower-level pieces:
- WAL/frontier concepts,
- recovery/catch-up/rebuild mechanics,
- peer readiness facts,
- promotion-ready evidence,
- stale-primary fencing gates.
But productized returned-replica lifecycle requires a Kubernetes-visible loop:
```text
returned replica observed
-> fenced from frontend
-> classified catch-up or rebuild
-> progress visible
-> barrier/terminal evidence observed
-> readiness changes
-> placement/ACK eligibility updated
```
Without that loop, claiming returned-replica rebuild would be too broad.
## Methodology
Returned-replica rebuild must answer:
```text
what facts prove the replica is stale?
what frontier must it cover?
who decides catch-up vs rebuild?
who executes transfer?
what barrier proves completion?
who changes readiness/ACK eligibility?
where does the user see progress and failure?
```
## State Machine
```mermaid
stateDiagram-v2
[*] --> Absent
Absent --> ReturnedObserved: replica pod/status endpoint returns
ReturnedObserved --> Fenced: frontend/ACK eligibility blocked
Fenced --> CatchingUp: WAL window sufficient
Fenced --> Rebuilding: WAL window insufficient
CatchingUp --> Verifying: required frontier covered
Rebuilding --> Verifying: base + WAL complete
Verifying --> Ready: barrier and readiness evidence valid
Verifying --> Blocked: evidence missing, stale, or failed
Ready --> [*]: eligible by policy
Blocked --> Fenced: retry with new evidence
```
## Implementation Areas
| Responsibility | Code / doc area |
|---|---|
| promotion readiness facts | `core/host/master/promotion_probe.go`, product loop tests |
| frontend fail-closed projection | `core/host/volume/projection_bridge.go`, `core/frontend/durable/` |
| recovery mechanics | recovery/transport code and older recovery tutorial |
| ManagedVolume status | `core/ops` future returned-replica projection |
| action ownership | operation-layer action model and future executor |
## What Exists Today
| Existing piece | Why it is not enough alone |
|---|---|
| recovery/catch-up mechanics | not yet a full Kubernetes-visible lifecycle claim |
| promotion-ready gates | prove candidate readiness for promotion, not returned-replica reintegration |
| stale primary fencing | prevents old writer, but does not rebuild old replica |
| ManagedVolume model | can expose facts, but needs returned-replica states/actions |
| operation-layer action model | can host future rebuild action contracts, but no executor yet |
## QA Gate Shape Needed
A real returned-replica gate should prove:
```text
replica returns stale
frontend remains fenced
catch-up/rebuild path starts with named reason
progress is visible in CRD/report/dashboard
dirty/stale evidence does not become Ready
barrier/completion evidence arrives
replica becomes ready only after frontier is covered
multi-volume isolation holds
cleanup verifier remains clean
```
## Non-Claims
- No automated returned-replica rebuild is currently claimed.
- No failback policy is claimed.
- No backup/restore is implied.
- No broad HA production claim follows from lower-level recovery code alone.
## Why This Is Next After Operation Layer
Operation-layer v0.5 created the shape needed for this work:
```text
facts -> judgment -> action -> boundary -> evidence
```
Returned-replica rebuild should be the next major storage feature only if it
uses that shape. Otherwise it will recreate the old problem: engine semantics
that look coherent internally but are not a complete product capability.
+3 -1
View File
@@ -110,7 +110,9 @@ Acceptance:
[x] block engine / WAL dirty-failure deep dive
[x] CSI + SwBlockVolume lifecycle deep dive
[x] TestOps scenario authoring deep dive
[ ] returned-replica rebuild readiness deep dive
[x] authority / epoch / promotion deep dive
[x] iSCSI ALUA / multipath deep dive
[x] returned-replica rebuild readiness deep dive
```
## D4: Publish / Serve Decision
+3
View File
@@ -46,6 +46,9 @@ nav:
- Operation Layer v0.5: wiki/deep-dives/operation-layer-v05.md
- ManagedVolume Readiness: wiki/deep-dives/managed-volume-readiness.md
- SmartWAL Dirty Failure: wiki/deep-dives/smartwal-dirty-failure.md
- Authority And Promotion: wiki/deep-dives/authority-promotion.md
- iSCSI ALUA Multipath: wiki/deep-dives/iscsi-alua-multipath.md
- Returned Replica Rebuild: wiki/deep-dives/returned-replica-rebuild.md
- TestOps Authoring: wiki/deep-dives/testops-authoring.md
- Product:
- Overview: overview.md