mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
docs: integrate local reclaim liveness model and mutant configs
This commit is contained in:
1 parent
e6a15049e9
commit
41b6783a95
11 files changed
+253
-3
No files matched your search
@@ -283,9 +283,10 @@ snapshot lifetime; local persistence does not bypass it.
|
||||
`TestWALStoreV3PressureSyncFaultDoesNotPublishFrontiers`,
|
||||
`TestWALStoreV3PressureSyncSkipsInstalling`,
|
||||
`TestWALStoreV3PressureProgressWithPendingCutOrClose` and
|
||||
`TestWALStoreV3PressureWaitBudgetAndPin`. Model correspondence/receipt is pending
|
||||
the parallel LIGHT internal-sync/reclaim liveness review; no model PASS is
|
||||
claimed by this source change.
|
||||
`TestWALStoreV3PressureWaitBudgetAndPin`. Model correspondence: `WALReclaim.tla` I1/I2/I3 and
|
||||
`AllWritten`/`NoStuckWaiter` in `REC_safe`/`REC_safe_big`; the no-internal-sync
|
||||
mutant violates liveness. Prior authored LIGHT receipts are referenced in
|
||||
`docs/spec/README.md`; this change does not claim a new TLC execution.
|
||||
- The v3 pressure admission budget is four seconds of cooperative waiting. It
|
||||
cannot preempt a blocking occupancy/closed callback, lock acquisition or
|
||||
physical file I/O. An unresolved pin or local stall returns
|
||||
|
||||
@@ -274,3 +274,31 @@ Recover/reset snapshot recheck and saved-file readers are covered by the
|
||||
native `TestCutCOWV3_*` caller controls, not claimed as model proofs.
|
||||
The earlier thirteen-spec parse statement above predates this imported model;
|
||||
no new independent TLC/parse or cloud run is claimed here.
|
||||
|
||||
|
||||
### WAL pressure progress without guest Sync
|
||||
|
||||
`WALReclaim.tla` models native local pressure persistence and checkpoint/reuse
|
||||
progress. `InternalSync` is weakly fair and does not take the capture lock;
|
||||
`GuestSync` has no fairness requirement. `REC_safe.cfg` and `REC_safe_big.cfg`
|
||||
check I1/I2/I3, ring/pin safety, `AllWritten` and `NoStuckWaiter`. Removing internal
|
||||
sync (`REC_red_noInternalSync.cfg`) violates liveness; removing the durable clamp
|
||||
violates I2. The capture-lock mutant and permanently held pin also violate
|
||||
liveness. The Go implementation bounds a permanent pin with retryable admission
|
||||
expiry rather than assuming that it always releases.
|
||||
|
||||
Run, from `docs/spec`, with the existing TLC tool:
|
||||
|
||||
```sh
|
||||
java -cp /path/to/tla2tools.jar tlc2.TLC -deadlock -config cfg/REC_safe.cfg WALReclaim
|
||||
java -cp /path/to/tla2tools.jar tlc2.TLC -deadlock -config cfg/REC_red_noInternalSync.cfg WALReclaim
|
||||
```
|
||||
|
||||
The authored LIGHT receipts report exhaustive safe searches at 2,700 and 25,550
|
||||
states, plus the expected mutant/witness failures. Source and configs are copied
|
||||
from the sealed `claude05-walreclaim-tla-r0-20261119` artifact with line-ending
|
||||
normalization only. Those are prior author runs, not a claim that this PR reran
|
||||
TLC. This is an abstraction: physical fsync success, byte layout, crash recovery,
|
||||
both-slot retirement, timing and multiple writers remain covered by their other
|
||||
models and actual Go controls. Do not treat finite liveness checking as an
|
||||
end-to-end wall-clock latency guarantee. Keep long model runs off tp04.
|
||||
@@ -0,0 +1,119 @@
|
||||
----------------------------- MODULE WALReclaim -----------------------------
|
||||
(***************************************************************************)
|
||||
(* Liveness of v3 WAL reclaim under write pressure (claude05, 2026-11-19). *)
|
||||
(* Abstracts core/storage at seaweed-block main 39f11d6a: *)
|
||||
(* head = WAL head LSN (records appended) *)
|
||||
(* wack = durable WAL frontier; today advanced only by Sync *)
|
||||
(* (walstore_v3.go:829) *)
|
||||
(* flushed = records the flusher has written to the extent *)
|
||||
(* ckpt = checkpoint = reuse floor, clamped to *)
|
||||
(* min(flushed, wack, session pin) *)
|
||||
(* (walstore_map_checkpoint_v3.go:57-62) *)
|
||||
(* A writer may append only while head - ckpt < Cap (the hard watermark). *)
|
||||
(* A blocked writer waits INSIDE the capture read lock *)
|
||||
(* (walstore.go:829-832, admission at :850). A cut takes the capture *)
|
||||
(* write lock; Go's RWMutex makes a pending writer block new readers. *)
|
||||
(* *)
|
||||
(* InternalOn: the fix under review (codex03 design r0) - under pressure *)
|
||||
(* the store makes its own WAL durable (wack := head) with no guest Sync. *)
|
||||
(* Mut: *)
|
||||
(* "none" the design *)
|
||||
(* "noClamp" checkpoint ignores wack (reclaims non-durable WAL) *)
|
||||
(* "syncTakesCapture" the internal sync needs the capture read lock *)
|
||||
(* (finding F2) *)
|
||||
(* PinFair: a catch-up session pin is eventually released (finding F3). *)
|
||||
(* The guest's Sync has NO fairness: a guest may never flush. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Naturals
|
||||
|
||||
CONSTANTS Cap, MaxLSN, MaxCuts, MaxPins, InternalOn, Mut, PinOn, PinFair
|
||||
|
||||
VARIABLES head, wack, flushed, ckpt, inside, cutPending, cuts, pin, pins, gsync
|
||||
|
||||
vars == <<head, wack, flushed, ckpt, inside, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
Min(a, b) == IF a < b THEN a ELSE b
|
||||
NoPin == MaxLSN + 1
|
||||
Full == head - ckpt >= Cap
|
||||
|
||||
Init == /\ head = 0 /\ wack = 0 /\ flushed = 0 /\ ckpt = 0
|
||||
/\ inside = FALSE /\ cutPending = FALSE /\ cuts = 0 /\ pin = NoPin /\ pins = 0 /\ gsync = FALSE
|
||||
|
||||
\* A writer that finds the ring full enters the admission wait holding the
|
||||
\* capture read lock; it can enter only if no cut is pending.
|
||||
EnterWait == /\ head < MaxLSN /\ Full /\ ~inside /\ ~cutPending
|
||||
/\ inside' = TRUE
|
||||
/\ UNCHANGED <<head, wack, flushed, ckpt, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
\* Append: a fresh writer needs the read lock (blocked by a pending cut); a
|
||||
\* writer already inside the wait holds it.
|
||||
Append == /\ head < MaxLSN /\ ~Full /\ (inside \/ ~cutPending)
|
||||
/\ head' = head + 1 /\ inside' = FALSE
|
||||
/\ UNCHANGED <<wack, flushed, ckpt, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
\* Guest Flush/Sync: may happen or never (no fairness).
|
||||
GuestSync == /\ wack < head
|
||||
/\ wack' = head /\ gsync' = TRUE
|
||||
/\ UNCHANGED <<head, flushed, ckpt, inside, cutPending, cuts, pin, pins>>
|
||||
|
||||
\* The fix: internal sync on pressure. In the mutant it also needs the
|
||||
\* capture read lock, so it is blocked while a cut is pending.
|
||||
InternalSync == /\ InternalOn /\ wack < head /\ Full
|
||||
/\ (Mut = "syncTakesCapture" => ~cutPending)
|
||||
/\ wack' = head
|
||||
/\ UNCHANGED <<head, flushed, ckpt, inside, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
Flush == /\ flushed < head
|
||||
/\ flushed' = flushed + 1
|
||||
/\ UNCHANGED <<head, wack, ckpt, inside, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
Target == IF Mut = "noClamp" THEN Min(flushed, pin) ELSE Min(Min(flushed, wack), pin)
|
||||
|
||||
Checkpoint == /\ Target > ckpt
|
||||
/\ ckpt' = Target
|
||||
/\ UNCHANGED <<head, wack, flushed, inside, cutPending, cuts, pin, pins, gsync>>
|
||||
|
||||
\* A cut requests the capture write lock; it completes once no reader holds
|
||||
\* the lock (the waiting writer is a reader).
|
||||
CutStart == /\ cuts < MaxCuts /\ ~cutPending
|
||||
/\ cutPending' = TRUE /\ cuts' = cuts + 1
|
||||
/\ UNCHANGED <<head, wack, flushed, ckpt, inside, pin, pins, gsync>>
|
||||
CutFinish == /\ cutPending /\ ~inside
|
||||
/\ cutPending' = FALSE
|
||||
/\ UNCHANGED <<head, wack, flushed, ckpt, inside, cuts, pin, pins, gsync>>
|
||||
|
||||
\* An RF2 catch-up session pins the WAL at the current checkpoint, later
|
||||
\* releases it.
|
||||
PinSet == /\ PinOn /\ pin = NoPin /\ pins < MaxPins
|
||||
/\ pin' = ckpt /\ pins' = pins + 1
|
||||
/\ UNCHANGED <<head, wack, flushed, ckpt, inside, cutPending, cuts, gsync>>
|
||||
PinRelease == /\ pin # NoPin
|
||||
/\ pin' = NoPin
|
||||
/\ UNCHANGED <<head, wack, flushed, ckpt, inside, cutPending, cuts, pins, gsync>>
|
||||
|
||||
Next == \/ EnterWait \/ Append \/ GuestSync \/ InternalSync \/ Flush \/ Checkpoint
|
||||
\/ CutStart \/ CutFinish \/ PinSet \/ PinRelease
|
||||
|
||||
Fairness == /\ WF_vars(Append) /\ WF_vars(EnterWait) /\ WF_vars(Flush) /\ WF_vars(Checkpoint)
|
||||
/\ WF_vars(InternalSync) /\ WF_vars(CutFinish)
|
||||
/\ (PinFair => WF_vars(PinRelease))
|
||||
|
||||
Spec == Init /\ [][Next]_vars /\ Fairness
|
||||
|
||||
\* ---- safety ----
|
||||
TypeOK == /\ head \in 0..MaxLSN /\ wack \in 0..MaxLSN /\ flushed \in 0..MaxLSN
|
||||
/\ ckpt \in 0..MaxLSN /\ inside \in BOOLEAN /\ cutPending \in BOOLEAN
|
||||
/\ cuts \in 0..MaxCuts /\ pin \in 0..(MaxLSN + 1) /\ pins \in 0..MaxPins /\ gsync \in BOOLEAN
|
||||
I1 == wack <= head \* durable frontier never ahead of the head
|
||||
I2 == ckpt <= wack \* never reclaim WAL that is not durable
|
||||
I3 == ckpt <= flushed \* never reclaim a record not yet in the extent
|
||||
IRing == head - ckpt <= Cap \* the ring never overflows
|
||||
IPin == pin # NoPin => ckpt >= pin \* a pin never moves the floor backwards (sanity)
|
||||
|
||||
\* ---- witness: all writes complete with NO guest Sync (must be violated = reachable when InternalOn) ----
|
||||
W_NeedsGuestSync == ~(head = MaxLSN /\ ~gsync)
|
||||
|
||||
\* ---- liveness ----
|
||||
AllWritten == <>(head = MaxLSN) \* no write stalls forever
|
||||
NoStuckWaiter == [](inside => <>(~inside)) \* a waiting writer is always admitted
|
||||
=============================================================================
|
||||
@@ -0,0 +1,12 @@
|
||||
\* REC_red_noClamp
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = TRUE
|
||||
Mut = "noClamp"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_red_noInternalSync
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = FALSE
|
||||
Mut = "none"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing
|
||||
PROPERTY AllWritten
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_red_pinForever
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = TRUE
|
||||
Mut = "none"
|
||||
PinOn = TRUE
|
||||
PinFair = FALSE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing
|
||||
PROPERTY AllWritten
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_red_syncTakesCapture
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = TRUE
|
||||
Mut = "syncTakesCapture"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing
|
||||
PROPERTY AllWritten
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_red_syncTakesCapture_big
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 3
|
||||
MaxLSN = 9
|
||||
MaxCuts = 3
|
||||
MaxPins = 2
|
||||
InternalOn = TRUE
|
||||
Mut = "syncTakesCapture"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing
|
||||
PROPERTY AllWritten
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_safe
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = TRUE
|
||||
Mut = "none"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing IPin
|
||||
PROPERTY AllWritten NoStuckWaiter
|
||||
@@ -0,0 +1,13 @@
|
||||
\* REC_safe_big
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 3
|
||||
MaxLSN = 9
|
||||
MaxCuts = 3
|
||||
MaxPins = 2
|
||||
InternalOn = TRUE
|
||||
Mut = "none"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT TypeOK I1 I2 I3 IRing IPin
|
||||
PROPERTY AllWritten NoStuckWaiter
|
||||
@@ -0,0 +1,12 @@
|
||||
\* REC_wit_noGuestSync
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Cap = 2
|
||||
MaxLSN = 5
|
||||
MaxCuts = 2
|
||||
MaxPins = 1
|
||||
InternalOn = TRUE
|
||||
Mut = "none"
|
||||
PinOn = TRUE
|
||||
PinFair = TRUE
|
||||
INVARIANT W_NeedsGuestSync
|
||||
Reference in new issue
Block a user