mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
test: specify certified prefix pruning and recovery coverage guards
This commit is contained in:
1 parent
85bf19a8bb
commit
ed08492b87
9 files changed
+61
-2
No files matched your search
@@ -12,7 +12,7 @@ func TestHealthyPrefixRequiresCompletedRecoveryAndPostCloseAck(t *testing.T) {
|
||||
t.Fatal("recovery close certified before post-close ack")
|
||||
}
|
||||
}
|
||||
result = Apply(st, DurableAckObserved{ReplicaID: "r1", SessionID: 8, EndpointVersion: 1, TransportEpoch: 1, DurableLSN: 120, PrimaryTailLSN: 1, PrimaryHeadLSN: 120})
|
||||
result = Apply(st, DurableAckObserved{ReplicaID: "r1", EndpointVersion: 1, TransportEpoch: 1, DurableLSN: 120, PrimaryTailLSN: 1, PrimaryHeadLSN: 120})
|
||||
for _, command := range result.Commands {
|
||||
if healthy, ok := command.(PublishHealthy); ok {
|
||||
if healthy.CertifiedPrefix != 100 || healthy.RecoverySessionID != 8 || healthy.Epoch != 1 || healthy.EndpointVersion != 1 {
|
||||
|
||||
@@ -299,6 +299,7 @@ stateDiagram-v2
|
||||
Degraded --> CatchingUp: gap within the primary's WAL
|
||||
CatchingUp --> CatchingUp: identical recovery facts retain the prepared session
|
||||
Healthy --> Healthy: delayed probe retains completed durable R
|
||||
Healthy --> Healthy: completed recovery certifies P, prune version suffix
|
||||
CatchingUp --> Healthy: caught up to the target
|
||||
CatchingUp --> Degraded: catch-up fails
|
||||
Degraded --> Healthy: recovers
|
||||
|
||||
@@ -114,6 +114,13 @@ stateDiagram-v2
|
||||
Excluded --> Supporting: later fact lists self as a peer
|
||||
```
|
||||
|
||||
The apply gate retains versions only above its certified contiguous prefix P.
|
||||
Completed recovery plus post-close healthy publication sends an explicit full-lineage
|
||||
certificate; current listener admission and the durable boundary guard it. Sync R,
|
||||
ordinary live traffic and session changes do not advance P. This implementation
|
||||
prunes at successful recovery certification only; healthy-run growth remains an
|
||||
RF2 qualification limitation until ordered-live certification is wired.
|
||||
|
||||
**Host role and listener admission.**
|
||||
|
||||
| From | To | Event and guard | Enforced in | Protects |
|
||||
@@ -135,7 +142,7 @@ stateDiagram-v2
|
||||
|---|---|---|---|---|
|
||||
| `Healthy`, `Unknown` | `Degraded` or `CatchingUp` | ship, barrier or fence failure; or a probe that needs catch-up | `core/replication/peer.go` `ReplicaPeer.SetState`, `replicaStateTransitionAllowed` | `INV-REPL-PEER-TRANSITIONS-001` |
|
||||
| `Degraded` | `CatchingUp` or `NeedsRebuild` | the engine decides catch-up when the gap is in the primary's WAL, rebuild when it is not | `core/engine/apply.go` `decide` | `INV-REPL-RECOVERY-SESSION-UNIQUE-001` | Each runtime observation selects at most one recovery session; delayed same-identity facts cannot restart a completed prefix, while a higher primary head or replacement identity still permits new work. | M3 recovery observation / preparation | `core/adapter/adapter.go`, `normalize.go`; `core/engine/apply.go` | `TestAdapter_OneRecoveryFromPostCloseStalledAck`, `TestAdapter_OneRecoveryPreparedWithinProbeBatch`, `TestAdapter_ConcurrentOldProbesNeverRestartHealthyRecovery`, `TestAdapter_ProbeUsesFreshBoundsBeforePreparingRecovery`, `TestRecoveryProbeKeepsCompletedRButAllowsNewWorkAndIdentity`, `TestC5_OrderStableAcrossRuns` | `ReplicaApplyOrder` NoDuplicateRecovery | ACTIVE |
|
||||
| `INV-REPL-NO-PER-LBA-DATA-REGRESSION` | Successful applies share a replica-wide per-LBA version across all sessions and lanes. Stale recovery advances only its own coverage; stale live entries fail. Closing a session or merging a lower seed cannot erase the applied version; failed physical writes do not publish it. Restart safety still requires substrate seeds. | M3 replica apply / session release | `core/replication/apply_gate.go`; blockvolume `replicationIngress` | `TestReplicationIngressSharesApplyVersionsAcrossSessions`, `TestApplyGate_OverlappingSessionsNeverRegressBytes`, `TestApplyGate_AlreadyAdmittedWireSessionNeverRegressesBytes`, `TestApplyGate_CloseAndLowerSeedNeverEraseReplicaVersion`, `TestApplyGate_FailedWriteDoesNotPublishReplicaVersion` | `ReplicaApplyOrder` NoRegression | ACTIVE |
|
||||
| `INV-REPL-NO-PER-LBA-DATA-REGRESSION` | Successful applies share a replica-wide per-LBA version across all sessions and lanes. Stale recovery advances only its own coverage; stale live entries fail. Closing a session or merging a lower seed cannot erase the applied version; failed physical writes do not publish it. Only an explicit completed-recovery prefix certificate advances P and prunes entries at/below P; the floor still rejects/skips old records. Synced R is not a certificate. Restart safety still requires substrate seeds. | M3 replica apply / session release | `core/replication/apply_gate.go`; blockvolume `replicationIngress` | `TestReplicationIngressSharesApplyVersionsAcrossSessions`, `TestApplyGate_OverlappingSessionsNeverRegressBytes`, `TestApplyGate_AlreadyAdmittedWireSessionNeverRegressesBytes`, `TestApplyGate_CloseAndLowerSeedNeverEraseReplicaVersion`, `TestApplyGate_FailedWriteDoesNotPublishReplicaVersion`, `TestApplyGate_CertifiedRecoveryClosesBoundVersionHistory`, `TestApplyGate_PrunedDurableVersionsRemainStale`, `TestApplyGate_CertifiedPrefixFreezesAcrossSessions`, `TestApplyGate_SyncedLiveMaximumDoesNotCoverRecoveryHole`, `TestApplyGate_HealthyRecoveryPublishesWirePrefix`, `TestApplyGate_WirePrefixCannotIntroduceOrReviveSession` | `ReplicaApplyOrder` NoRegression; `ReplicaPrefixFloor` NoRegression/CertifiedCoverage/OnlySuffix | ACTIVE |
|
||||
| `INV-REPL-CATCHUP-REBUILD-001` |
|
||||
| `CatchingUp` | `Healthy`, `Degraded` or `NeedsRebuild` | done-acknowledgement; failure; WAL recycled or retries exhausted | `core/replication/peer.go` `ReplicaPeer.SetState` | `INV-REPL-PEER-TRANSITIONS-001` |
|
||||
| any but `NeedsRebuild` | `Healthy` | recovered | `core/replication/peer.go` `replicaStateTransitionAllowed` | `INV-REPL-PEER-TRANSITIONS-001` |
|
||||
|
||||
@@ -320,3 +320,10 @@ HostBudget also models guarded configuration initialization: staged bytes are in
|
||||
## Replica apply ordering
|
||||
|
||||
`ReplicaApplyOrder.tla` models two admitted sessions on one LBA with three versions, plus the two events of one probe and a delayed post-completion probe. `R292_safe` checks `NoRegression`, `NoDuplicateRecovery` and `NoFalseKnown`; the four `R292_red_*` configurations remove one guard each. It abstracts successful physical applies only: it does not establish restart persistence, authority, byte-level framing, or I/O deadlines.
|
||||
|
||||
`ReplicaPrefixFloor.tla` checks two LBAs/three source versions with explicit
|
||||
covered-prefix certification, suffix pruning and stale checks against the floor.
|
||||
`R293_prefix_safe` checks `NoRegression`, `CertifiedCoverage`, and `OnlySuffix`;
|
||||
its two negative controls infer a prefix from the synced maximum or omit the
|
||||
floor after pruning. It does not establish the wire certificate's provenance,
|
||||
restart persistence, live-prefix extension, or a fixed memory cap without closes.
|
||||
@@ -0,0 +1,31 @@
|
||||
----------------------- MODULE ReplicaPrefixFloor -----------------------
|
||||
EXTENDS Integers, TLC
|
||||
CONSTANTS UseFloor, CertifiedOnly
|
||||
VARIABLES data, seen, versions, durable, prefix
|
||||
vars == <<data, seen, versions, durable, prefix>>
|
||||
Addr(n) == IF n = 2 THEN 2 ELSE 1
|
||||
Max(a,b) == IF a > b THEN a ELSE b
|
||||
Covered(p) == \A n \in 1..p : data[Addr(n)] >= n
|
||||
Init == /\ data = [i \in 1..2 |-> 0] /\ seen = data /\ versions = data
|
||||
/\ durable = 0 /\ prefix = 0
|
||||
Apply(n) == LET i == Addr(n)
|
||||
threshold == Max(versions[i], IF UseFloor THEN prefix ELSE 0)
|
||||
IN /\ data' = IF n > threshold THEN [data EXCEPT ![i] = n] ELSE data
|
||||
/\ seen' = [seen EXCEPT ![i] = Max(@,n)]
|
||||
/\ versions' = IF n > threshold THEN [versions EXCEPT ![i] = n] ELSE versions
|
||||
/\ UNCHANGED <<durable,prefix>>
|
||||
Sync == /\ durable' = Max(durable, Max(data[1],data[2]))
|
||||
/\ UNCHANGED <<data,seen,versions,prefix>>
|
||||
Certify(p) == /\ p > prefix /\ p <= durable
|
||||
/\ (~CertifiedOnly \/ Covered(p))
|
||||
/\ prefix' = p
|
||||
/\ versions' = [i \in 1..2 |-> IF versions[i] <= p THEN 0 ELSE versions[i]]
|
||||
/\ UNCHANGED <<data,seen,durable>>
|
||||
\* Session changes, ordinary live writes, disconnects and Sync do not certify.
|
||||
RestartSession == UNCHANGED vars
|
||||
Next == (\E n \in 1..3 : Apply(n)) \/ Sync \/ (\E p \in 1..3 : Certify(p)) \/ RestartSession
|
||||
Spec == Init /\ [][Next]_vars
|
||||
NoRegression == data = seen
|
||||
CertifiedCoverage == Covered(prefix)
|
||||
OnlySuffix == \A i \in 1..2 : versions[i] = 0 \/ versions[i] > prefix
|
||||
=============================================================================
|
||||
@@ -0,0 +1,4 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS UseFloor = FALSE
|
||||
CertifiedOnly = TRUE
|
||||
INVARIANTS NoRegression CertifiedCoverage OnlySuffix
|
||||
@@ -0,0 +1,4 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS UseFloor = TRUE
|
||||
CertifiedOnly = FALSE
|
||||
INVARIANTS NoRegression CertifiedCoverage OnlySuffix
|
||||
@@ -0,0 +1,4 @@
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS UseFloor = TRUE
|
||||
CertifiedOnly = TRUE
|
||||
INVARIANTS NoRegression CertifiedCoverage OnlySuffix
|
||||
@@ -25,6 +25,7 @@ case $cfg in
|
||||
S4_*) spec=CutCapture ;;
|
||||
S5_*) spec=ControlPlane ;;
|
||||
S6_*) spec=ReplicationFailover ;;
|
||||
R293_prefix_*) spec=ReplicaPrefixFloor ;;
|
||||
R292_*) spec=ReplicaApplyOrder ;;
|
||||
S9b_*) spec=RetentionGCMulti ;;
|
||||
S9_*) spec=RetentionGCTiming ;;
|
||||
|
||||
Reference in new issue
Block a user