mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
docs/spec: add TLA+ models of the volume lifecycle, takeover, WAL recovery, cut pipeline and GC timing
docs/spec/ holds 12 TLA+ models of the block protocols with their TLC configurations (cfg/, 199 files: designs, RED configs that remove one guard and must produce a counterexample, and reachability witnesses), run.sh to check one configuration, and a README: how to run TLC, one row per spec (invariants, results, the code it maps to), limits, the findings that led to #152, #156, #158 and #159, and the open model-level items. Docs only; nothing runs in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba3bbfe25b
commit
cd16a2a90b
213 files changed
+7186
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,99 @@
|
||||
----------------------------- MODULE ControlPlane -----------------------------
|
||||
(***************************************************************************)
|
||||
(* S5 (first slice): the blockmaster authority store and guarded moves. *)
|
||||
(* One volume, its durable record {epoch, holder, move journal}, two move *)
|
||||
(* requests (request ids) that clients retry, durable Puts whose outcome *)
|
||||
(* may be unknown (landed or not), and blockmaster restarts that reload *)
|
||||
(* the record (core/authority at 1e8b0e9d). *)
|
||||
(* *)
|
||||
(* A move (applyWithWorkspaceMove, authority.go:435-575, prepare *)
|
||||
(* workspace.go:287-335), under Publisher.mu: *)
|
||||
(* 1. an issued journal entry for the request id -> replay its record; *)
|
||||
(* 2. a reserved, unissued entry -> resume with the SAME epoch; *)
|
||||
(* 3. else reserve: epoch = max(published, journal) + 1, persist the *)
|
||||
(* journal with the OLD assignment (first Put), then *)
|
||||
(* 4. persist the new assignment with the entry marked issued (2nd Put). *)
|
||||
(* A failed Put leaves the outcome unknown: the volume is marked uncertain *)
|
||||
(* and refuses workspace changes until a restart reloads the store *)
|
||||
(* (workspace.go:254-269, authority.go:563-569). *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS Rids, MaxRestarts, MaxTries,
|
||||
UncertainGuard, \* RED FALSE: a failed Put does not mark the volume uncertain
|
||||
ReserveFirst \* RED FALSE: mint and issue in one Put, without the reservation step
|
||||
|
||||
Target(r) == r \* each request moves the volume to its own holder (model value)
|
||||
|
||||
VARIABLES store, mem, uncertain, pend, tries, restarts, issued
|
||||
vars == <<store, mem, uncertain, pend, tries, restarts, issued>>
|
||||
|
||||
Rec0 == [epoch |-> 1, holder |-> "h0", moves |-> {}]
|
||||
|
||||
Init == /\ store = Rec0 /\ mem = Rec0 /\ uncertain = FALSE
|
||||
/\ pend = [r \in Rids |-> 0] /\ tries = [r \in Rids |-> 0]
|
||||
/\ restarts = 0 /\ issued = <<>>
|
||||
|
||||
Max(S) == IF S = {} THEN 0 ELSE CHOOSE m \in S : \A s \in S : s <= m
|
||||
Entry(rec, r) == {m \in rec.moves : m.rid = r}
|
||||
NextEpoch(rec) == Max({rec.epoch} \cup {m.e : m \in rec.moves}) + 1
|
||||
Issue(rec, r, e) == [epoch |-> e, holder |-> Target(r),
|
||||
moves |-> {m \in rec.moves : m.rid # r} \cup {[rid |-> r, e |-> e, ok |-> TRUE]}]
|
||||
Logged(new) == IF new.epoch # store.epoch \/ new.holder # store.holder
|
||||
THEN Append(issued, [e |-> new.epoch, holder |-> new.holder]) ELSE issued
|
||||
|
||||
\* a durable Put: lands and is acknowledged, fails without landing, or lands with its reply lost
|
||||
Put(new, okNext) ==
|
||||
\/ /\ store' = new /\ mem' = new /\ issued' = Logged(new) /\ okNext /\ uncertain' = uncertain
|
||||
\/ /\ store' = store /\ mem' = mem /\ issued' = issued /\ uncertain' = (UncertainGuard \/ uncertain)
|
||||
/\ pend' = pend
|
||||
\/ /\ store' = new /\ issued' = Logged(new) /\ mem' = mem /\ uncertain' = (UncertainGuard \/ uncertain)
|
||||
/\ pend' = pend
|
||||
|
||||
\* steps 1-3 (one critical section up to the first Put)
|
||||
Request(r) ==
|
||||
/\ ~uncertain /\ pend[r] = 0 /\ tries[r] < MaxTries
|
||||
/\ tries' = [tries EXCEPT ![r] = @ + 1]
|
||||
/\ restarts' = restarts
|
||||
/\ LET ent == Entry(mem, r) IN
|
||||
IF \E m \in ent : m.ok
|
||||
THEN /\ UNCHANGED <<store, mem, uncertain, pend, issued>> \* replay
|
||||
\* prepare refuses unless the current line is the request's expected one (workspace.go:291-295):
|
||||
\* every request here expects the initial assignment (epoch 1)
|
||||
ELSE IF mem.epoch # 1
|
||||
THEN /\ UNCHANGED <<store, mem, uncertain, pend, issued>>
|
||||
ELSE IF ent # {}
|
||||
THEN LET e == (CHOOSE m \in ent : TRUE).e \* resume the reservation
|
||||
IN Put(Issue(mem, r, e), pend' = pend)
|
||||
ELSE LET e == NextEpoch(mem)
|
||||
IN IF ReserveFirst
|
||||
THEN Put([mem EXCEPT !.moves = @ \cup {[rid |-> r, e |-> e, ok |-> FALSE]}], pend' = [pend EXCEPT ![r] = e])
|
||||
ELSE Put(Issue(mem, r, e), pend' = pend)
|
||||
|
||||
\* step 4, still under the lock (nothing else runs between the two Puts; a restart may)
|
||||
IssueStep(r) ==
|
||||
/\ pend[r] # 0 /\ ~uncertain
|
||||
/\ LET e == pend[r] IN
|
||||
Put(Issue(mem, r, e), pend' = [pend EXCEPT ![r] = 0])
|
||||
/\ UNCHANGED <<tries, restarts>>
|
||||
|
||||
Restart == /\ restarts < MaxRestarts
|
||||
/\ restarts' = restarts + 1
|
||||
/\ mem' = store /\ uncertain' = FALSE /\ pend' = [r \in Rids |-> 0]
|
||||
/\ UNCHANGED <<store, tries, issued>>
|
||||
|
||||
\* the lock: while a request holds a pending reservation, no other request starts
|
||||
Next == \/ \E r \in Rids : (\A q \in Rids : pend[q] = 0) /\ Request(r)
|
||||
\/ \E r \in Rids : IssueStep(r)
|
||||
\/ Restart
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
\* no epoch is ever issued to two holders, and issued epochs strictly increase
|
||||
UniqueEpoch == \A i, j \in 1..Len(issued) : i < j => issued[i].e < issued[j].e
|
||||
\* each request id is issued at most one epoch
|
||||
Idempotent == \A r \in Rids : Cardinality({i \in 1..Len(issued) : issued[i].holder = Target(r)}) <= 1
|
||||
\* every issued epoch is journaled with its request (the grant record exists before the epoch is visible)
|
||||
JournalComplete == store.epoch > 1 => \E m \in store.moves : m.e = store.epoch /\ m.ok
|
||||
W_Moved == Len(issued) = 0
|
||||
=============================================================================
|
||||
@@ -0,0 +1,150 @@
|
||||
------------------------------ MODULE CutCapture ------------------------------
|
||||
(***************************************************************************)
|
||||
(* S4 (with the S6 failover slice): which chunks must the next cut upload? *)
|
||||
(* Compares the dirty BITMAP (core/storage/chunk_layer.go at 1e8b0e9d) *)
|
||||
(* with a proposed per-chunk LAST-WRITE-LSN map, across RF=1 restart, *)
|
||||
(* crash mid-cut, and RF=2 failover to a replica. *)
|
||||
(* *)
|
||||
(* Writes get LSN = position in `hist` (the current lineage). A cut takes *)
|
||||
(* a barrier at frontier L, captures the chunks it believes changed since *)
|
||||
(* HEAD at their value as of L, then CASes HEAD {lsn L, image}. Chunk *)
|
||||
(* content is abstracted to "the LSN of the write it holds". *)
|
||||
(* *)
|
||||
(* Track: *)
|
||||
(* "bitmap" dirty set in memory; persisted before a WAL checkpoint *)
|
||||
(* passes its entries (BeforeCheckpointAdvance, :353-361); *)
|
||||
(* recovery = persisted set + chunks of WAL entries above *)
|
||||
(* the checkpoint; after a cut, bits stay only for chunks *)
|
||||
(* written after the barrier (finishCut :1542-1559). Not *)
|
||||
(* replicated: a promoted replica starts with an empty set. *)
|
||||
(* "bitmapHash" as bitmap, but a node whose bitmap is not bound to the *)
|
||||
(* current HEAD starts in hashMode (:95, :186-216): every *)
|
||||
(* chunk is a candidate for the next cut. *)
|
||||
(* "lsnmap" lastLSN[c] = LSN of the last write to c; replicas apply *)
|
||||
(* the same writes with the same LSNs; dirty-since-HEAD = *)
|
||||
(* {c : lastLSN[c] > HEAD.lsn}; persisted like the bitmap. *)
|
||||
(* A BASE-rebuilt replica seeds lastLSN = base for all. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS Chunks, MaxLSN, MaxCuts, Track, Mode,
|
||||
PersistBeforeCkpt, \* RED FALSE: checkpoint passes entries before the dirty state is durable
|
||||
ClearAtCapture, \* RED TRUE: clear dirty state at the barrier, before the HEAD CAS
|
||||
ReplDurableOnly, \* TRUE: in rf2 a cut covers only the replicated-durable frontier
|
||||
BaseLSN \* rf2: R was BASE-rebuilt at this LSN (0: R replicated from the start)
|
||||
|
||||
Nodes == {"P", "R"}
|
||||
Zero == [c \in Chunks |-> 0]
|
||||
|
||||
VARIABLES hist, prim, alive, applied, synced, ckpt,
|
||||
dmem, ddisk, mmem, mdisk, \* bitmap (mem/disk) and lsn map (mem/disk) per node
|
||||
bound, \* the persisted dirty state is bound to the current HEAD (bitmap header)
|
||||
head, cut, cuts, events
|
||||
vars == <<hist, prim, alive, applied, synced, ckpt, dmem, ddisk, mmem, mdisk, bound, head, cut, cuts, events>>
|
||||
|
||||
ValueAt(c, L) == LET ws == {i \in 1..L : i <= Len(hist) /\ hist[i] = c} IN IF ws = {} THEN 0 ELSE CHOOSE m \in ws : \A k \in ws : k <= m
|
||||
Max(S) == IF S = {} THEN 0 ELSE CHOOSE m \in S : \A s \in S : s <= m
|
||||
Min2(a, b) == IF a < b THEN a ELSE b
|
||||
|
||||
Init ==
|
||||
/\ hist = [i \in 1..BaseLSN |-> CHOOSE c \in Chunks : TRUE]
|
||||
/\ prim = "P" /\ alive = [n \in Nodes |-> TRUE]
|
||||
/\ applied = [n \in Nodes |-> BaseLSN] /\ synced = [n \in Nodes |-> BaseLSN] /\ ckpt = [n \in Nodes |-> BaseLSN]
|
||||
/\ dmem = [n \in Nodes |-> IF n = "P" /\ BaseLSN > 0 THEN {CHOOSE c \in Chunks : TRUE} ELSE {}]
|
||||
/\ ddisk = dmem
|
||||
/\ mmem = [n \in Nodes |-> IF n = "P" /\ BaseLSN > 0 THEN [c \in Chunks |-> ValueAt(c, BaseLSN)]
|
||||
ELSE IF BaseLSN > 0 THEN [c \in Chunks |-> BaseLSN] ELSE Zero]
|
||||
/\ mdisk = mmem
|
||||
/\ bound = [n \in Nodes |-> n = "P"]
|
||||
/\ head = [lsn |-> 0, img |-> Zero]
|
||||
/\ cut = [pc |-> "idle", L |-> 0, D |-> {}, cap |-> Zero]
|
||||
/\ cuts = 0
|
||||
/\ events = 0
|
||||
|
||||
Repl == Mode = "rf2"
|
||||
|
||||
\* a VM write on the primary (WALStore write -> chunk layer OnExtentWrite, :299-310)
|
||||
Write(c) == /\ Len(hist) < MaxLSN /\ alive[prim]
|
||||
/\ hist' = Append(hist, c)
|
||||
/\ applied' = [applied EXCEPT ![prim] = Len(hist) + 1]
|
||||
/\ dmem' = [dmem EXCEPT ![prim] = @ \cup {c}]
|
||||
/\ mmem' = [mmem EXCEPT ![prim][c] = Len(hist) + 1]
|
||||
/\ UNCHANGED <<prim, alive, synced, ckpt, ddisk, mdisk, bound, head, cut, cuts, events>>
|
||||
|
||||
\* the replica applies the next shipped write with the same LSN (ApplyEntry)
|
||||
ReplApply == /\ Repl /\ alive["R"] /\ prim = "P" /\ applied["R"] < Len(hist)
|
||||
/\ LET i == applied["R"] + 1 IN
|
||||
/\ applied' = [applied EXCEPT !["R"] = i]
|
||||
/\ mmem' = [mmem EXCEPT !["R"][hist[i]] = i]
|
||||
/\ UNCHANGED <<hist, prim, alive, synced, ckpt, dmem, ddisk, mdisk, bound, head, cut, cuts, events>>
|
||||
|
||||
Sync(n) == /\ alive[n] /\ synced[n] < applied[n]
|
||||
/\ synced' = [synced EXCEPT ![n] = applied[n]]
|
||||
/\ UNCHANGED <<hist, prim, alive, applied, ckpt, dmem, ddisk, mmem, mdisk, bound, head, cut, cuts, events>>
|
||||
|
||||
\* the flusher passes WAL entries <= synced; the dirty state is saved first (BeforeCheckpointAdvance)
|
||||
Checkpoint(n) == /\ alive[n] /\ ckpt[n] < synced[n]
|
||||
/\ ckpt' = [ckpt EXCEPT ![n] = synced[n]]
|
||||
/\ ddisk' = IF PersistBeforeCkpt THEN [ddisk EXCEPT ![n] = dmem[n]] ELSE ddisk
|
||||
/\ mdisk' = IF PersistBeforeCkpt THEN [mdisk EXCEPT ![n] = mmem[n]] ELSE mdisk
|
||||
/\ UNCHANGED <<hist, prim, alive, applied, synced, dmem, mmem, bound, head, cut, cuts>>
|
||||
/\ events' = events
|
||||
|
||||
\* the dirty state a node can rebuild after a restart: persisted + WAL entries above the checkpoint
|
||||
WalChunks(n) == {hist[i] : i \in {j \in (ckpt[n] + 1)..synced[n] : j <= Len(hist)}}
|
||||
WalMap(n) == [c \in Chunks |-> LET ws == {i \in (ckpt[n] + 1)..synced[n] : i <= Len(hist) /\ hist[i] = c}
|
||||
IN IF ws = {} THEN mdisk[n][c] ELSE Max(ws)]
|
||||
|
||||
\* RF=1: the primary crashes and restarts; unsynced writes are gone; a cut in flight is lost
|
||||
Restart == /\ ~Repl /\ events < 1 /\ alive["P"]
|
||||
/\ hist' = SubSeq(hist, 1, synced["P"])
|
||||
/\ applied' = [applied EXCEPT !["P"] = synced["P"]]
|
||||
/\ dmem' = [dmem EXCEPT !["P"] = IF Track = "bitmapHash" /\ ~bound["P"] THEN Chunks ELSE ddisk["P"] \cup WalChunks("P")]
|
||||
/\ mmem' = [mmem EXCEPT !["P"] = WalMap("P")]
|
||||
/\ cut' = [pc |-> "idle", L |-> 0, D |-> {}, cap |-> Zero]
|
||||
/\ events' = events + 1
|
||||
/\ UNCHANGED <<prim, alive, synced, ckpt, ddisk, mdisk, bound, head, cuts>>
|
||||
|
||||
\* RF=2: P dies, R is promoted with what it applied (acked writes are replicated-durable)
|
||||
Failover == /\ Repl /\ events < 1 /\ prim = "P"
|
||||
/\ prim' = "R" /\ alive' = [alive EXCEPT !["P"] = FALSE]
|
||||
/\ hist' = SubSeq(hist, 1, applied["R"])
|
||||
/\ dmem' = [dmem EXCEPT !["R"] = IF Track = "bitmapHash" THEN Chunks ELSE {}] \* R has no bitmap for HEAD
|
||||
/\ cut' = [pc |-> "idle", L |-> 0, D |-> {}, cap |-> Zero]
|
||||
/\ events' = events + 1
|
||||
/\ UNCHANGED <<applied, synced, ckpt, ddisk, mmem, mdisk, bound, head, cuts>>
|
||||
|
||||
Frontier == IF Repl /\ prim = "P" /\ ReplDurableOnly THEN Min2(synced["P"], synced["R"]) ELSE synced[prim]
|
||||
Dirty(n) == IF Track = "lsnmap" THEN {c \in Chunks : mmem[n][c] > head.lsn} ELSE dmem[n]
|
||||
|
||||
\* the barrier: frontier L, the believed dirty set, the captured values as of L
|
||||
CutBegin == /\ cut.pc = "idle" /\ cuts < MaxCuts /\ alive[prim] /\ Frontier > head.lsn
|
||||
/\ LET L == Frontier
|
||||
D == Dirty(prim)
|
||||
IN /\ cut' = [pc |-> "cas", L |-> L, D |-> D, cap |-> [c \in Chunks |-> IF c \in D THEN ValueAt(c, L) ELSE head.img[c]]]
|
||||
/\ dmem' = IF ClearAtCapture THEN [dmem EXCEPT ![prim] = @ \ D] ELSE dmem
|
||||
/\ UNCHANGED <<hist, prim, alive, applied, synced, ckpt, ddisk, mmem, mdisk, bound, head, cuts, events>>
|
||||
|
||||
\* the HEAD CAS (refused below HEAD's remote_lsn: lsn_behind), then finishCut keeps the bits of
|
||||
\* chunks written after the barrier and persists the set bound to the new HEAD
|
||||
CutCAS == /\ cut.pc = "cas" /\ alive[prim]
|
||||
/\ head' = [lsn |-> cut.L, img |-> cut.cap]
|
||||
/\ LET still == {c \in Chunks : \E i \in (cut.L + 1)..Len(hist) : hist[i] = c}
|
||||
IN dmem' = [dmem EXCEPT ![prim] = IF ClearAtCapture THEN @ ELSE (@ \ cut.D) \cup still]
|
||||
/\ bound' = [n \in Nodes |-> n = prim]
|
||||
/\ cut' = [pc |-> "idle", L |-> 0, D |-> {}, cap |-> Zero]
|
||||
/\ cuts' = cuts + 1
|
||||
/\ UNCHANGED <<hist, prim, alive, applied, synced, ckpt, ddisk, mmem, mdisk, events>>
|
||||
|
||||
Next == \/ \E c \in Chunks : Write(c)
|
||||
\/ ReplApply \/ Restart \/ Failover \/ CutBegin \/ CutCAS
|
||||
\/ \E n \in Nodes : Sync(n) \/ Checkpoint(n)
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
\* HEAD is the exact image of the current lineage at HEAD.lsn: the cut uploaded every chunk changed since HEAD
|
||||
HeadImage == \A c \in Chunks : head.img[c] = ValueAt(c, head.lsn)
|
||||
\* HEAD never covers more than the current primary has durably
|
||||
HeadLeDurable == ~alive[prim] \/ (head.lsn <= Len(hist) /\ head.lsn <= synced[prim])
|
||||
W_CutAfterEvent == ~(events > 0 /\ cuts >= 2)
|
||||
=============================================================================
|
||||
@@ -0,0 +1,89 @@
|
||||
----------------------------- MODULE CutPipeline -----------------------------
|
||||
(***************************************************************************)
|
||||
(* S4 (remainder): the cut pipeline at main 1e8b0e9d. *)
|
||||
(* - precopy rounds upload chunks before the barrier, tagged with the *)
|
||||
(* chunk's mutation generation (chunkMut, chunk_layer.go:107-111, 349); *)
|
||||
(* at the barrier a precopied upload is reused only if the generation *)
|
||||
(* is unchanged, else the chunk is copied under the barrier; *)
|
||||
(* - two-level manifest: each segment object lists its chunks; a segment *)
|
||||
(* is rewritten iff one of its chunks is in the cut's set, else the old *)
|
||||
(* segment object is reused; the root (HEAD) CAS publishes them *)
|
||||
(* (#151, docs/chunk-manifests.md); *)
|
||||
(* - restart without a bound bitmap starts reconciling (hashMode): every *)
|
||||
(* chunk is compared against HEAD; cuts are refused ("reconciling") *)
|
||||
(* until the compare finishes (chunk_layer.go:95); *)
|
||||
(* - a crash before the root CAS leaves only orphan uploads. *)
|
||||
(* Chunk content = the LSN of the write it holds. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS MaxLSN, MaxCuts, MaxPre,
|
||||
GenCheck, \* RED FALSE: reuse a precopied upload without comparing generations
|
||||
SegRewrite, \* RED FALSE: reuse the old segment object even if a chunk in it changed
|
||||
RefuseReconcile \* RED FALSE: allow a cut while the reconcile compare is incomplete
|
||||
|
||||
Chunks == {"a", "b", "c"}
|
||||
Segs == {"s1", "s2"}
|
||||
SegOf == [c \in Chunks |-> IF c = "c" THEN "s2" ELSE "s1"]
|
||||
|
||||
VARIABLES hist, mut, dirty, pre, head, recon, cuts, pres, restarted
|
||||
vars == <<hist, mut, dirty, pre, head, recon, cuts, pres, restarted>>
|
||||
|
||||
Val(c, L) == LET ws == {i \in 1..L : hist[i] = c} IN IF ws = {} THEN 0 ELSE CHOOSE m \in ws : \A k \in ws : k <= m
|
||||
Cur(c) == Val(c, Len(hist))
|
||||
None == [v |-> -1, g |-> -1]
|
||||
Init == /\ hist = <<>> /\ mut = [c \in Chunks |-> 0] /\ dirty = {}
|
||||
/\ pre = [c \in Chunks |-> None]
|
||||
/\ head = [lsn |-> 0, img |-> [c \in Chunks |-> 0], seg |-> [s \in Segs |-> [c \in Chunks |-> 0]]]
|
||||
/\ recon = [c \in Chunks |-> TRUE] \* TRUE: this chunk's dirty state is known
|
||||
/\ cuts = 0 /\ pres = 0 /\ restarted = FALSE
|
||||
|
||||
Write(c) == /\ Len(hist) < MaxLSN
|
||||
/\ hist' = Append(hist, c) /\ mut' = [mut EXCEPT ![c] = @ + 1] /\ dirty' = dirty \cup {c}
|
||||
/\ UNCHANGED <<pre, head, recon, cuts, pres, restarted>>
|
||||
|
||||
\* precopy: upload the chunk's current content outside the barrier, tagged with its generation
|
||||
Precopy(c) == /\ c \in dirty /\ pres < MaxPre
|
||||
/\ pre' = [pre EXCEPT ![c] = [v |-> Cur(c), g |-> mut[c]]]
|
||||
/\ pres' = pres + 1
|
||||
/\ UNCHANGED <<hist, mut, dirty, head, recon, cuts, restarted>>
|
||||
|
||||
\* restart with a lost/unbound bitmap: dirty state unknown, reconcile every chunk against HEAD
|
||||
Restart == /\ ~restarted
|
||||
/\ recon' = [c \in Chunks |-> FALSE] /\ dirty' = {} /\ pre' = [c \in Chunks |-> None]
|
||||
/\ restarted' = TRUE
|
||||
/\ UNCHANGED <<hist, mut, head, cuts, pres>>
|
||||
\* the bounded background compare: one chunk against HEAD
|
||||
Reconcile(c) == /\ ~recon[c]
|
||||
/\ recon' = [recon EXCEPT ![c] = TRUE]
|
||||
/\ dirty' = IF Cur(c) # head.img[c] THEN dirty \cup {c} ELSE dirty
|
||||
/\ UNCHANGED <<hist, mut, pre, head, cuts, pres, restarted>>
|
||||
|
||||
\* the barrier + capture + manifest + root CAS, as one step (a crash before it leaves orphans only)
|
||||
Cut == /\ cuts < MaxCuts /\ Len(hist) > head.lsn
|
||||
/\ RefuseReconcile => \A c \in Chunks : recon[c]
|
||||
/\ LET L == Len(hist)
|
||||
D == dirty
|
||||
up(c) == IF c \notin D THEN head.img[c]
|
||||
ELSE IF pre[c] # None /\ (~GenCheck \/ pre[c].g = mut[c]) THEN pre[c].v
|
||||
ELSE Val(c, L)
|
||||
img == [c \in Chunks |-> up(c)]
|
||||
seg == [s \in Segs |-> IF SegRewrite /\ \E c \in D : SegOf[c] = s
|
||||
THEN [c \in Chunks |-> IF SegOf[c] = s THEN img[c] ELSE 0]
|
||||
ELSE IF ~SegRewrite /\ head.lsn = 0
|
||||
THEN [c \in Chunks |-> IF SegOf[c] = s THEN img[c] ELSE 0]
|
||||
ELSE head.seg[s]]
|
||||
IN /\ head' = [lsn |-> L, img |-> img, seg |-> seg]
|
||||
/\ dirty' = {} \* finishCut: no write lands inside the atomic cut
|
||||
/\ pre' = [c \in Chunks |-> None]
|
||||
/\ cuts' = cuts + 1
|
||||
/\ UNCHANGED <<hist, mut, recon, pres, restarted>>
|
||||
|
||||
Next == (\E c \in Chunks : Write(c) \/ Precopy(c) \/ Reconcile(c)) \/ Restart \/ Cut
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
\* HEAD (root and every segment) is the exact image of the history at HEAD.lsn
|
||||
HeadImage == \A c \in Chunks : head.img[c] = Val(c, head.lsn)
|
||||
SegConsistent == \A c \in Chunks : head.seg[SegOf[c]][c] = head.img[c]
|
||||
W_TwoCuts == cuts < 2
|
||||
=============================================================================
|
||||
@@ -0,0 +1,218 @@
|
||||
# Formal specifications (TLA+)
|
||||
|
||||
This directory holds TLA+ models of the sw-block protocols where a bug would
|
||||
lose or corrupt data: volume and snapshot lifecycle, epoch fencing and
|
||||
takeover, local WAL crash recovery, the cut (HEAD publish) pipeline, the
|
||||
control-plane authority store, RF=2 failover, and GC timing.
|
||||
|
||||
The models check **designs**, not the Go code. Each one is small, each
|
||||
abstracts a lot, and each is mapped to the code by hand (see
|
||||
[Limits](#limits)). They have already paid for themselves: several of the
|
||||
counterexamples below were turned into fixes (#152, #156, #158, #159).
|
||||
|
||||
Code references are `path:line` at main **`5c7c1a7f`** unless a row says
|
||||
otherwise. Comments inside the `.tla` files cite lines at the commit named in
|
||||
each file's header; this README is the current map.
|
||||
|
||||
## TLA+ and TLC in one paragraph
|
||||
|
||||
[TLA+](https://github.com/tlaplus/tlaplus) describes a system as a
|
||||
state machine: an initial state (`Init`) and a relation (`Next`) that says
|
||||
which steps may follow any state. Concurrency is modelled as interleaving, so
|
||||
every order of remote calls, crashes, lost replies and timeouts that the spec
|
||||
allows is a possible behaviour. **TLC** is the explicit-state model checker:
|
||||
for a configuration (`cfg/*.cfg`) that fixes small values for the constants
|
||||
(2 volumes, 4 writes, ...), it enumerates *every* reachable state and checks
|
||||
the invariants in each. A pass means "no violation exists within these
|
||||
bounds"; a violation comes with the shortest trace that reaches it. **SANY**
|
||||
is the parser and semantic checker that ships in the same jar.
|
||||
|
||||
## Running
|
||||
|
||||
**Tools.** Java 11 or newer (the runs below used Java 17 and 21) and
|
||||
`tla2tools.jar` **v1.7.4** (TLC2 version 2.19):
|
||||
|
||||
```sh
|
||||
curl -fLO https://github.com/tlaplus/tlaplus/releases/download/v1.7.4/tla2tools.jar
|
||||
echo "936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88 tla2tools.jar" | sha256sum -c -
|
||||
```
|
||||
|
||||
**Parse only** (seconds; useful after an edit):
|
||||
|
||||
```sh
|
||||
cd docs/spec
|
||||
java -cp /path/to/tla2tools.jar tla2sany.SANY WorkspaceTakeover.tla
|
||||
```
|
||||
|
||||
**Model-check one configuration.** `run.sh` picks the spec from the config
|
||||
name prefix:
|
||||
|
||||
```sh
|
||||
cd docs/spec
|
||||
TLA2TOOLS=/path/to/tla2tools.jar ./run.sh Fix_token
|
||||
# equivalent raw command:
|
||||
java -XX:+UseParallelGC -Xmx4g -cp /path/to/tla2tools.jar tlc2.TLC \
|
||||
-config cfg/Fix_token.cfg -deadlock -workers auto -metadir states/Fix_token \
|
||||
ChunkLifecycleFixed.tla
|
||||
```
|
||||
|
||||
- `-deadlock` turns deadlock checking **off**. Several models have a process
|
||||
that loops forever (GC), and bounded models stop at their bounds.
|
||||
- `-workers auto` uses every core; 8 workers is a good default on a laptop.
|
||||
- Memory: most configs fit in `-Xmx4g`. The large ones (`Fix_P1`,
|
||||
`Fix_P2_aba`, `W4_drift_heads`, anything `_big` or `_large`) want
|
||||
`-Xmx8g` or more and a fast disk for `states/`. The `_large` configs ran for
|
||||
tens of minutes on 30 workers.
|
||||
- `ChunkLifecycle.tla` and `ChunkLifecycleFixed.tla` are PlusCal. After
|
||||
editing the algorithm, re-translate with
|
||||
`java -cp tla2tools.jar pcal.trans -nocfg ChunkLifecycleFixed.tla`.
|
||||
- For a quick random search of a config too large to finish, add
|
||||
`-simulate -depth 400` (not exhaustive).
|
||||
|
||||
**Reading results.** `Model checking completed. No error has been found.` is
|
||||
a pass for that config. `Invariant X is violated` prints the trace.
|
||||
Two kinds of config are **expected to violate**:
|
||||
|
||||
- `*_red_*`, `RED_*`, `Bug_*`: a guard is removed (a constant set to the
|
||||
"unsafe" value) or the pre-fix design is used. The violation shows that
|
||||
the guard or fix is load-bearing.
|
||||
- `*_reach_*`, `W_*` invariants: reachability witnesses ("this good state is
|
||||
never reached"). Their violation shows that the model can actually do the
|
||||
thing (delete, take over, publish), so a pass elsewhere is not vacuous.
|
||||
|
||||
## Files
|
||||
|
||||
| Spec | Configs | Kind |
|
||||
|---|---|---|
|
||||
| `ChunkLifecycleFixed.tla` | `cfg/Fix_*` | current design (PlusCal) |
|
||||
| `ChunkLifecycle.tla` | `cfg/Bug_*` | historical: the pre-fix design of #152, kept for its counterexamples |
|
||||
| `WorkspaceTakeover.tla` | `cfg/W4_*`, `cfg/RED_*` | |
|
||||
| `WALRecovery.tla` | `cfg/S3_wal_*`, `cfg/S3v*`, `cfg/S3r_*`, `cfg/S3m_*`, `cfg/S3f_*` | |
|
||||
| `SmartWALRecovery.tla` | `cfg/S3_sw_*`, `cfg/S3_sw2_*` | |
|
||||
| `WALReplica.tla` | `cfg/S3_rep_*` | |
|
||||
| `CutCapture.tla` | `cfg/S4_*` | |
|
||||
| `CutPipeline.tla` | `cfg/S4b_*` | |
|
||||
| `ControlPlane.tla` | `cfg/S5_*` | |
|
||||
| `ReplicationFailover.tla` | `cfg/S6_*` | design-level |
|
||||
| `RetentionGCTiming.tla` | `cfg/S9_*` | |
|
||||
| `RetentionGCMulti.tla` | `cfg/S9b_*` | |
|
||||
|
||||
Each `.cfg` names its spec on its first line.
|
||||
|
||||
## Specs at a glance
|
||||
|
||||
State counts are distinct states for exhaustive passes. "N-step trace" is the
|
||||
length of TLC's shortest counterexample.
|
||||
|
||||
| # | Spec | What it models | Key invariants | Results | Code (at `5c7c1a7f`) |
|
||||
|---|---|---|---|---|---|
|
||||
| S1 | `ChunkLifecycleFixed` (+ historical `ChunkLifecycle`) | Chunk HEAD, capture intents, snapshots (name record + attempt path), fork claims, tombstones, GC mark+sweep, and volume delete with a blockmaster deletion reservation. Actors: host, 0-2 snapshot callers, a fork, explicit DeleteSnapshot callers, 1-3 volume deleters with reruns, CreateVolume, GC. Filer semantics: conditional write on HEAD gen, exclusive create, conditional update/delete, uncancellable late create. | `GCSafe`, `SnapOnlyExplicitDelete`, `CommitClean`, `NoPublishAfterCommit`, `AckedChunksSurvive`, `NoIdReuse`, `GiveBackReleases`, temporal `HeadMonotone` | **Fixed design, all pass:** `Fix_P1` 51,375,412; `Fix_P2_aba` 46,245,848; `Fix_mix_small` 29,194,420; `Fix_token` 41,256; `Fix_create` 100. `Fix_mix` no violation in 138M states (20-min limit, incomplete). All `Fix_reach_*` reached. **Historical (pre-fix) counterexamples:** `Bug_P1_mark` (18-step), `Bug_P1_giveback` (23), `Bug_P1_data` (25: GC reclaims an acked snapshot's chunk), `Bug_P2_aba` (22), `Bug_token` (16), `Bug_create` (7). | `core/frontend/chunkstore/volume_delete.go:106` DeleteVolume (incarnation loop `:150`), `:269` markHeadDeleting, `:400` snapshotsBlock, `:314` revertHeadDeleting, `:347` commitHeadPurging; `catalog.go:824` CreateSnapshot (gate `:863`), `:943` claimName, `:771` createResolved, `:1058` DeleteSnapshot, `:1157` Fork, `:1337` claimForkParent, `:709` AbortSnapshot, `:1438` AbortFork; `retention.go:448` markDeleting, `:570` liveClaims; `gc.go:108` Collector.run; `chunk_remote.go:404` CASHead refuses delete states; `core/host/master/services.go:53` CreateVolume (holds workspaceMu `:64`), `:132` MarkVolumeDeleting; `core/lifecycle/deletion_reservations.go:111` Admit; `cmd/sw-block/chunk_volume_delete.go:32` `--request-id` |
|
||||
| S2 | `WorkspaceTakeover` | A workspace volume moving from host A (epoch 1) to host B by a clean move (detach, revoke, ACK, assign) or a forced move (lease expiry). Blockmaster clock, host clock lag up to `Drift`, lossy and reordered messages, master restart, each host's cut as one remote call per step, takeover CAS, GC intent expiry. Code pinned at `5c293821`. | `NoDualServing`, `NoOldCasAfterTakeover`, `NoLateChunkReachable`, `GCSafe`, `NoLiveIntentExpired`, `CleanNoLoss`, `ForcedLossBounded`, `SeedMatchesTakeover`, temporal `HeadMonotone` | **Pass:** `W4_clean` 6,048,496; `W4_forced` 22,619,644; `W4_drift_heads` 56,242,345; `W4_clean_large` 590,137,925 (depth 70). `W4_forced_large`: no violation in 910,907,693 states (time limit, incomplete). **RED:** `RED_early_assign` NoDualServing (12-step); `RED_gc_ageonly` GCSafe (12); `RED_epoch` NoOldCasAfterTakeover (22-24); `RED_lsn` HeadMonotone (24). `RED_epoch_storeonly`/`_hostonly` pass (438,406 / 827,500): either epoch check alone suffices. `RED_lsn_storeonly` passes (28,389,024). **Findings:** `W4_drift` NoDualServing (13-step, fixed by #158, see below); `W4_forced_exact` ForcedLossExact (16-step, benign, open). | `core/frontend/chunkstore/chunk_remote.go:390` CASHead (epoch guard `:391`, gen/epoch/LSN guard `:409`, conditional update `:420`); `core/host/volume/workspace_lease.go:57` permits, `:70` Refresh (anchor `:73`, accept `:117`); `core/authority/workspace.go:95` RenewWorkspaceLease, `:222` BeginWorkspaceRevocation, `:237` AckWorkspaceRevocation, `:309` prepareWorkspaceMoveLocked (forced-move margin `:316-320`); `core/host/master/workspace_service.go:109` MoveWorkspace (HEAD read `:116`); `core/authority/authority.go:251` reloadFromStore (deadline reset `:261`); `core/frontend/durable/provider_chunk.go:289` PrepareRestore, `:309` ClaimChunkHead; `core/storage/chunk_restore.go:14`; `core/storage/chunk_layer.go:680` captureLocked (admit `:695`, lsn_behind `:800`, PutIntent `:853`, re-admit `:911`, supersededBy `:916`, CAS `:926`, settle `:972`); `core/frontend/chunkstore/gc.go:221` intent-expiry epoch rule |
|
||||
| S3 | `WALRecovery`, `SmartWALRecovery`, `WALReplica` | Local WAL crash recovery. **walstore:** a ring of K pages, 1-2 page records, page cache written back in any order, Sync, flusher checkpoint, crash at any point with optionally one corrupted record page; recovery is a pure function of the durable image, with a selectable `Rule`. **smartwal:** in-place extent write plus a metadata ring slot, written back in any order, torn slots. **Replica:** RF=2 classification and promotion eligibility, BASE jump. | `I1` every synced write is recovered (or superseded) or recovery fails closed; `I2` a crash without corruption never reports corruption; `ReplayLastWriter`; `I0Prefix`; `I1Frontier`; `NoForgedReplay`; `I3` the promoted node has every acked write | **walstore, current main** (rule `rootLww`, reuse bounded by the persisted tail): `S3r_rootLww_I1_crashonly`/`_I2`/`_replay` pass (849,003); with an in-memory rebuild jump `S3r_rebuild_rootLww_*` pass (1,460,772). **Pre-fix code:** `S3_wal_current_I1_crashonly` I1 violated (synced write lost after a plain crash, #156); `S3v_code_lww_I1_crashonly` I1 violated (LWW replay alone is not enough, #159). **Open:** one corrupted synced record `S3v1_root_lww_I1` violated; Sync-persisted watermark `S3m_*` pass (1,320,984 / 3,955,400); `S3f_*` NoForgedReplay violated (confirmed on main, see Open items). **smartwal, current:** `S3_sw_current_I2` violated (false `wal_corrupt`), `_I1`, `_I1frontier` violated; proposal `S3_sw2_ordered_marker_repair_I2` pass (65,401), `_I1slot` pass (345,084). **Replica:** `S3_rep_c1_I2` pass (29,196), `S3_rep_c1_g2_I2` pass (12,712), `S3_rep_c1_g1_I3` pass (74,527); RED `S3_rep_c2_I2`, `S3_rep_c1_g2jump_I2`, `S3_rep_nogate_I3` violated. | `core/storage/recovery.go:43` recoverWAL (head==tail scan from its position `:63-73`, defensive scan `:74-90`, a range stops at its first bad entry `:141`, `:154`, hole warning `:437`), LWW replay `:193` via `core/storage/dirty_map.go:56` putAtIfNewer; `core/storage/wal_writer.go:41` durableTail, `:70` spaceUsed, `:443` tailPersisted; `core/storage/walstore.go:390` checkpoint release, `:933` Sync, `:1065` AdvanceFrontier, `:1167` ApplyEntry; `core/storage/smartwal/store.go:297` writeAt (extent `:304`, then ring `:313`), `:345` Sync; `smartwal/recovery.go:47` runRecoveryCounting (fail closed `:99-100`); `smartwal/ring.go:45` appendAt, `:69` scanSlots; `core/replication/volume.go:680` RebaseShipLSN |
|
||||
| S4 | `CutCapture`, `CutPipeline` | Which chunks the next cut must upload: the dirty bitmap vs a per-chunk last-write-LSN map, across RF=1 restart, crash mid-cut and RF=2 failover; dirty state persisted before a checkpoint passes WAL entries. Then the pipeline: precopy tagged with a per-chunk mutation generation, two-level manifest segments, root CAS, and `reconciling` after a restart without a bound bitmap. | `HeadImage` (HEAD is the exact image of the lineage at HEAD.lsn), `HeadLeDurable`, `SegConsistent` | **Pass:** `S4_rf1_bitmap` 47,670, `S4_rf1_lsnmap` 46,934, `S4_rf2_bitmapHash` 7,166,376, `S4_rf2_lsnmap` 8,226,004, `S4_rf2_lsnmap_base` 901,390; `S4b_design` 69,645, `S4b_design_big` 1,515,837. **RED:** `S4_rf2_bitmap` (failover without hashMode, 7-step), `S4_rf2_lsnmap_localCut` (6), `S4_rf1_*_noPersist` (7), `S4_rf1_bitmap_clearEarly` (8); `S4b_red_noGen`, `S4b_red_cutWhileRec` HeadImage; `S4b_red_segReuse` SegConsistent. | `core/storage/chunk_layer.go:356` BeforeCheckpointAdvance, `:299` OnExtentWrite, `:95` hashMode (set on attach `:184-230`), `:111` chunkMut, `:324` noteMutation, `:762` and `:1435` staged upload reused only if its generation is unchanged, `:702-704` cut refused while reconciling, `:877-881` PrepareManifest, `:1542` finishCut; `core/frontend/chunkstore/manifest.go:101` segment reused only if its chunk refs are unchanged |
|
||||
| S5 | `ControlPlane` | Blockmaster authority store: one volume record `{epoch, holder, move journal}`, two retried move requests, durable Puts that succeed, fail, or land with the reply lost, and restarts. | `UniqueEpoch` (issued epochs strictly increase), `Idempotent` (one epoch per request id), `JournalComplete` | `S5_code` pass (298). **RED:** `S5_red_noUncertain` UniqueEpoch violated (5-step: a lost-reply Put, then a reservation from stale memory puts the old assignment back). `S5_red_noReserve` passes (the reservation step is not needed for these invariants). | `core/authority/authority.go:436` applyWithWorkspaceMove (uncertain refusal `:442-444`, Put `:564`, mark uncertain `:568`); `core/authority/workspace.go:309` prepareWorkspaceMoveLocked (expected line `:313`, resume a reserved entry `:324-333`, reserve max+1 `:344-355`), journal replay `:192-219`, persist and mark uncertain `:276-288` |
|
||||
| S6 | `ReplicationFailover` | RF=2: P ships to R, R acks what is durable, the client is acked when both are durable; promotion of R at a new epoch with an evidence gate; R refuses old-epoch shipping; cuts and snapshots cover only the replicated-durable frontier; an in-flight snapshot create from the old primary may still land after the failover. Design-level. | `AckedSurvive`, `HeadOnLineage`, `SnapOnLineage`, `NoStaleAck` | `S6_design` pass (52,897), `S6_design_big` (598,353). **RED:** `S6_red_localCut` HeadOnLineage; `S6_red_noFence` AckedSurvive. `S6_red_noEvidence` passes: with synchronous RF=2 acks the gate is redundant (it matters for quorum or async shipping, not modelled). | `core/transport/replica.go:362` replica rejects a stale-lineage ship entry; `core/replication/volume.go:680` RebaseShipLSN; takeover CAS as in S2 |
|
||||
| S9 | `RetentionGCTiming`, `RetentionGCMulti` | GC timing with an explicit clock: a copy operation with deadline D, marks of duration up to MD, deletion only after two marks at least Grace apart; then marks across two volumes with a fork and a snapshot delete. | `NoLiveDelete` | **Single op:** `S9_rule_G4` (G > D + MD) pass (10,798; `_big` 43,780); G = D passes (`S9_red_G2_noguard`, 11,953). **RED:** `S9_red_G1_noguard`, `S9_red_G1_D3` (G < D) NoLiveDelete violated. **Two volumes:** `S9b_G1_MD2`, `_G2_MD2`, `_G2_MD3`, `_G3_MD1` pass (5,743-9,079). | `core/frontend/chunkstore/gc.go:89` grace > operation deadline, `:280` mark-duration margin, `:306-318` two-mark rule, `:214-221` intent expiry; `catalog.go:896-905` intent deadline re-checked before publish; `gc_copy.go:143`, `:177` a deleting attempt stays a root until grace |
|
||||
|
||||
## Limits
|
||||
|
||||
- **Design, not code.** Each action is a hand-written abstraction of one
|
||||
remote call or one local decision, mapped to code by the table above. A
|
||||
pass says the *design* is safe under the modelled assumptions; it does not
|
||||
say the Go code implements that design. Line mappings were re-checked
|
||||
against `5c7c1a7f`, but they rot as code moves.
|
||||
- **Small scopes.** 2 volumes, 2-3 chunks, 2 snapshot names, 3-6 writes or
|
||||
LSNs, a 4-page WAL, 1-2 restarts, clocks up to 7-16 ticks. A pass is
|
||||
exhaustive *for that config only*. Some large configs stopped at a time
|
||||
limit; they are marked incomplete above.
|
||||
- **Abstractions.** Data is "the LSN of the write it holds" (no bytes); a CRC
|
||||
is data identity; one corrupted record at most; GC mark+sweep is atomic in
|
||||
S1 and S2 (S9 models its timing); time in S1 is replaced by a "keys read by
|
||||
an in-flight operation are roots" assumption; S1 has no epoch (S2 covers
|
||||
it) and no crash (so fsync-durability bugs are out of scope); some reads
|
||||
are merged with the conditional write they guard, which can only hide
|
||||
interleavings, never invent them.
|
||||
- **Not modelled.** RF=3 quorum, catch-up and rebuild, wall-clock jumps,
|
||||
master HA, an unknown-outcome HEAD CAS (`resolvePending`), the S2 forced
|
||||
move's skew margin added in #158, liveness under fairness.
|
||||
- **Model errors happen.** Three early drafts of these specs produced
|
||||
spurious violations that were traced to the model, not the code. Every
|
||||
violation listed here was checked against the code.
|
||||
|
||||
## Findings that led to code fixes
|
||||
|
||||
| PR | Finding | Spec / configs |
|
||||
|---|---|---|
|
||||
| #152 | Volume delete (as first proposed): (1) the snapshot cascade's back-out could mark *another* caller's published snapshot deleting while the delete was still provisional, so a later GC could reclaim an acknowledged snapshot's only chunk; (2) a claim check and commit not bound to one deletion incarnation allowed an ABA across three concurrent deleters; (3) a rerun with a fresh token left the first reservation held; (4) CreateVolume released its lock between the reservation check and the create. Fixed by refusing while any snapshot name exists, binding check, commit and revert to one incarnation, using `--request-id` as the token, and keeping the lock. | S1 `Bug_P1_*`, `Bug_P2_aba`, `Bug_token`, `Bug_create` (violated); `Fix_*` (pass) |
|
||||
| #156 | walstore recovery replayed in physical scan order. After a wrap, a newer record could be scanned before an older one for the same LBA and lose to it, so an acknowledged write was lost after a plain crash. Fixed by last-writer-wins replay by LSN. | S3 `S3_wal_current_I1_crashonly` |
|
||||
| #159 | With LWW replay alone, the writer could reuse WAL space released only in memory; a torn unsynced record written there could stop the scan before a synced record that the on-disk superblock still retained. Fixed by reusing only space the *persisted* tail released, and by scanning an empty-superblock window from its position. | S3 `S3v_code_lww_I1_crashonly` (violated); `S3r_rootLww_*`, `S3r_rebuild_rootLww_*` (pass) |
|
||||
| #158 | The workspace lease had no clock-skew margin: with a host clock one tick slow, the old and new host could both serve after a forced move (HEAD stayed safe because the old host's CAS fails on the epoch). Fixed by a skew margin: a forced move waits for lease expiry plus the margin (`core/authority/workspace.go:316-320`), and the lease validity reported to the host excludes half of it (`core/host/master/workspace_service.go:46-53`). | S2 `W4_drift` (violated against the pre-fix design; the margin is not yet in the model) |
|
||||
|
||||
The S2 epoch rule for GC intent expiry (`gc.go:221`), the S5 "uncertain
|
||||
after a failed Put" guard, and the S4 generation and reconciling guards were
|
||||
already in the code; their RED variants confirm they are load-bearing and
|
||||
are good candidates for regression tests.
|
||||
|
||||
## Open items
|
||||
|
||||
These are model-level results on the current design. They are not confirmed
|
||||
bugs in production paths unless stated.
|
||||
|
||||
1. **Corrupted synced WAL records need a format change (walstore).** If a
|
||||
synced record's bytes are corrupted, the current recovery stops that range
|
||||
at the bad record and continues; data after it in the range is dropped and
|
||||
recovery reports success (a hole warning is logged since #155). An
|
||||
in-record durable watermark alone is not enough (a corrupt *last* synced
|
||||
record leaves no valid witness). The configs that pass (`S3m_*`) need Sync
|
||||
to persist the watermark and any frontier jump out of band (for example in
|
||||
the superblock) before acknowledging, plus recovery that decodes every
|
||||
record position and replays by LSN.
|
||||
2. **Forged replay (confirmed, open).** Recovery accepts any well-formed
|
||||
record. A guest payload can contain bytes that decode as a valid WAL
|
||||
record (CRC32 is not keyed). If a newer, shorter record overwrites only the
|
||||
start of an old multi-block record, the scan continues into the old
|
||||
payload and replays the forged record. Every rule modelled, including the
|
||||
current one, violates `NoForgedReplay` (`S3f_*`).
|
||||
- **Reproduced on main.** A 3-block batch write carries an encoded WAL
|
||||
entry (LSN 999, LBA 7) in its guest data. After a newer 1-block record
|
||||
wraps over the batch's start, recovery decodes the embedded entry: LBA 7
|
||||
reads the forged data, and the frontier jumps to 999. This also happens
|
||||
after a clean close and reopen.
|
||||
- **Effect.** It stays inside the guest's own volume: a write at a chosen
|
||||
LBA, or a bogus LSN that moves the frontier.
|
||||
- **Planned fix.** An interim fix persists the WAL head on Close and adds
|
||||
a clean-shutdown flag. The full fix comes with the format change: bind
|
||||
each record to its WAL incarnation and lap, for example with an epoch or
|
||||
nonce in the header.
|
||||
3. **SmartWAL.**
|
||||
- The extent write and the ring slot have no ordering barrier
|
||||
(`smartwal/store.go:304`, `:313`), and recovery fails closed on any CRC
|
||||
mismatch (`smartwal/recovery.go:99`). After a plain crash an *unsynced*
|
||||
write can therefore make the volume refuse to start with `wal_corrupt`
|
||||
(`S3_sw_current_I2`): an availability problem, not data loss.
|
||||
- There is no per-block CRC once a slot has been recycled, so extent
|
||||
corruption of such an LBA is not detected, and corrupting the only record
|
||||
of a synced write lowers the recovered frontier silently
|
||||
(`S3_sw_current_I1`, `_I1frontier`; a documented limitation).
|
||||
- A proposal passes `I2` and slot-corruption `I1`: make the record durable
|
||||
before the data write, persist gap markers for frontier jumps, and have
|
||||
recovery durably settle every torn tail it accepts (`S3_sw2_ordered_marker_repair_*`).
|
||||
Its frontier still needs an out-of-band durable watermark (item 1).
|
||||
- The positional torn-slot rule of an earlier revision of #155 (089d2d9)
|
||||
could report `wal_corrupt` after a plain crash (`S3_sw2_pr155o_I2`); the
|
||||
merged #155 only counts torn slots, so this does not apply to main.
|
||||
4. **Design notes (no safety impact).** A forced move's journal records the
|
||||
HEAD read before the publisher lock (`workspace_service.go:116`), so it can
|
||||
over-report the loss window (`W4_forced_exact`). A refused snapshot attempt
|
||||
can leave an unpublished name record that blocks later volume deletes until
|
||||
`DeleteSnapshot` settles it (`Fix_reach_W_NoHiddenNameBlock`;
|
||||
`catalog.go:861`).
|
||||
|
||||
## Parse check
|
||||
|
||||
All 12 specs parse and pass SANY's semantic check with `tla2tools.jar` v1.7.4
|
||||
(`java -cp tla2tools.jar tla2sany.SANY <file>`), checked on 2026-11-16:
|
||||
`ChunkLifecycle`, `ChunkLifecycleFixed`, `ControlPlane`, `CutCapture`,
|
||||
`CutPipeline`, `ReplicationFailover`, `RetentionGCMulti`, `RetentionGCTiming`,
|
||||
`SmartWALRecovery`, `WALRecovery`, `WALReplica`, `WorkspaceTakeover`. The state counts above come from earlier
|
||||
TLC runs of these specs; comment-only edits were made since.
|
||||
@@ -0,0 +1,102 @@
|
||||
------------------------- MODULE ReplicationFailover -------------------------
|
||||
(***************************************************************************)
|
||||
(* S6 (first slice): RF=2 failover with chunk HEAD and snapshot handoff. *)
|
||||
(* Primary P ships writes to replica R; R acks what it made durable; the *)
|
||||
(* client gets an ack once P and R are durable. The master promotes R at *)
|
||||
(* epoch E+1 only with evidence (R durable >= every acked LSN). R rejects *)
|
||||
(* shipping from a lower epoch, so a partitioned old primary can no longer *)
|
||||
(* get acks. Cuts (chunk HEAD) cover only the replicated-durable frontier *)
|
||||
(* and are epoch-fenced CASes (S2). A snapshot request in flight at the *)
|
||||
(* failover is retried on the new primary with the same request id: it *)
|
||||
(* publishes to the same attempt path (exclusive create, cannot be *)
|
||||
(* cancelled), so whichever create lands first is the snapshot. *)
|
||||
(* Chunk content is abstracted to "the LSN of the write it holds"; one *)
|
||||
(* chunk per LBA, LBAs {a, b}. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS MaxLSN,
|
||||
ReplFrontier, \* RED FALSE: a cut or snapshot covers P's local durable LSN, not the replicated one
|
||||
EvidenceGate, \* RED FALSE: promote R without checking it has every acked write
|
||||
EpochFenceShip \* RED FALSE: R accepts shipping from the old epoch after promotion
|
||||
|
||||
LBAs == {"a", "b"}
|
||||
|
||||
VARIABLES hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, snap, pend, rhist
|
||||
vars == <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, snap, pend, rhist>>
|
||||
|
||||
Val(h, c, L) == LET ws == {i \in 1..L : i <= Len(h) /\ h[i] = c} IN IF ws = {} THEN 0 ELSE CHOOSE m \in ws : \A k \in ws : k <= m
|
||||
Img(h, L) == [c \in LBAs |-> Val(h, c, L)]
|
||||
|
||||
Init == /\ hist = <<>> /\ rhist = <<>> \* P's log and R's log
|
||||
/\ pDur = 0 /\ rApp = 0 /\ rDur = 0 /\ acked = 0
|
||||
/\ prim = "P" /\ epoch = 1 /\ pEpoch = 1
|
||||
/\ head = [lsn |-> 0, img |-> Img(<<>>, 0), epoch |-> 1]
|
||||
/\ snap = [st |-> "none", lsn |-> 0, img |-> Img(<<>>, 0)] \* the published snapshot (attempt path)
|
||||
/\ pend = [on |-> FALSE, lsn |-> 0, img |-> Img(<<>>, 0)] \* old primary's uncancellable create in flight
|
||||
|
||||
\* ---- primary P (old epoch) ----
|
||||
PWrite(c) == /\ Len(hist) < MaxLSN /\ hist' = Append(hist, c)
|
||||
/\ UNCHANGED <<pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, snap, pend, rhist>>
|
||||
PSync == pDur < Len(hist) /\ pDur' = Len(hist) /\ UNCHANGED <<hist, rApp, rDur, acked, prim, epoch, pEpoch, head, snap, pend, rhist>>
|
||||
\* R applies the next shipped write (refused from the old epoch after promotion)
|
||||
Ship == /\ rApp < Len(hist) /\ (prim = "P" \/ ~EpochFenceShip)
|
||||
/\ rApp' = rApp + 1 /\ rhist' = Append(rhist, hist[rApp + 1])
|
||||
/\ UNCHANGED <<hist, pDur, rDur, acked, prim, epoch, pEpoch, head, snap, pend>>
|
||||
RSync == rDur < rApp /\ rDur' = rApp /\ UNCHANGED <<hist, pDur, rApp, acked, prim, epoch, pEpoch, head, snap, pend, rhist>>
|
||||
\* the client ack: durable on P and R (old primary still acks if R accepted its shipping)
|
||||
Ack == /\ (prim = "P" \/ ~EpochFenceShip) \* after the fence R acks nothing for the old epoch
|
||||
/\ LET a == IF pDur < rDur THEN pDur ELSE rDur IN a > acked /\ acked' = a
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, prim, epoch, pEpoch, head, snap, pend, rhist>>
|
||||
|
||||
Frontier == IF ReplFrontier THEN (IF pDur < rDur THEN pDur ELSE rDur) ELSE pDur
|
||||
\* P's cut: epoch-fenced CAS (fails once the new primary has taken HEAD over)
|
||||
PCut == /\ prim = "P" /\ head.epoch = pEpoch /\ Frontier > head.lsn
|
||||
/\ head' = [lsn |-> Frontier, img |-> Img(hist, Frontier), epoch |-> pEpoch]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, snap, pend, rhist>>
|
||||
\* P starts the snapshot: its create is sent and may land at any later time
|
||||
PSnap == /\ prim = "P" /\ snap.st = "none" /\ ~pend.on /\ Frontier > 0
|
||||
/\ pend' = [on |-> TRUE, lsn |-> Frontier, img |-> Img(hist, Frontier)]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, snap, rhist>>
|
||||
Land == /\ pend.on
|
||||
/\ snap' = IF snap.st = "none" THEN [st |-> "published", lsn |-> pend.lsn, img |-> pend.img] ELSE snap
|
||||
/\ pend' = [pend EXCEPT !.on = FALSE]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, rhist>>
|
||||
|
||||
\* ---- failover ----
|
||||
Promote == /\ prim = "P" /\ (EvidenceGate => rDur >= acked)
|
||||
/\ prim' = "R" /\ epoch' = epoch + 1
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, pEpoch, head, snap, pend, rhist>>
|
||||
\* R's takeover CAS of HEAD at the new epoch (S2), from the HEAD it observed
|
||||
Takeover == /\ prim = "R" /\ head.epoch < epoch
|
||||
/\ head' = [head EXCEPT !.epoch = epoch]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, snap, pend, rhist>>
|
||||
RWrite(c) == /\ prim = "R" /\ head.epoch = epoch /\ Len(rhist) < MaxLSN
|
||||
/\ rhist' = Append(rhist, c) /\ rApp' = rApp + 1
|
||||
/\ UNCHANGED <<hist, pDur, rDur, acked, prim, epoch, pEpoch, head, snap, pend>>
|
||||
RCut == /\ prim = "R" /\ head.epoch = epoch /\ rDur > head.lsn
|
||||
/\ head' = [lsn |-> rDur, img |-> Img(rhist, rDur), epoch |-> epoch]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, snap, pend, rhist>>
|
||||
\* the retried snapshot request on R, same request id: same attempt path, exclusive create
|
||||
RSnap == /\ prim = "R" /\ head.epoch = epoch /\ snap.st = "none" /\ rDur > 0
|
||||
/\ snap' = [st |-> "published", lsn |-> rDur, img |-> Img(rhist, rDur)]
|
||||
/\ UNCHANGED <<hist, pDur, rApp, rDur, acked, prim, epoch, pEpoch, head, pend, rhist>>
|
||||
|
||||
Next == \/ \E c \in LBAs : PWrite(c) \/ RWrite(c)
|
||||
\/ PSync \/ Ship \/ RSync \/ Ack \/ PCut \/ PSnap \/ Land
|
||||
\/ Promote \/ Takeover \/ RCut \/ RSnap
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Lineage == IF prim = "R" THEN rhist ELSE hist
|
||||
\* the promoted primary holds every acknowledged write
|
||||
AckedSurvive == prim = "R" => (\A i \in 1..acked : i <= Len(rhist) /\ rhist[i] = hist[i])
|
||||
\* HEAD is a prefix image of the surviving lineage and never ahead of its durable LSN
|
||||
HeadOnLineage == /\ head.img = Img(Lineage, head.lsn)
|
||||
/\ (prim = "R" /\ head.epoch = epoch) => head.lsn <= rDur
|
||||
\* the published snapshot is a prefix image of the surviving lineage
|
||||
SnapOnLineage == snap.st = "published" => snap.img = Img(Lineage, snap.lsn)
|
||||
\* the old primary acks nothing after the promotion that the new primary lacks
|
||||
NoStaleAck == prim = "R" => acked <= Len(rhist)
|
||||
W_Handoff == ~(prim = "R" /\ snap.st = "published" /\ head.epoch = epoch /\ head.lsn > 0)
|
||||
=============================================================================
|
||||
@@ -0,0 +1,56 @@
|
||||
--------------------------- MODULE RetentionGCMulti ---------------------------
|
||||
(***************************************************************************)
|
||||
(* S9 (remainder): GC marks across two volumes, with a fork and a snapshot *)
|
||||
(* delete. Chunk k is rooted by P's snapshot M. A fork F <- P/M claims M, *)
|
||||
(* writes its intent in F, creates F's HEAD (which names k) and drops its *)
|
||||
(* intent and claim (catalog.go:1151-1311). Then M may be deleted *)
|
||||
(* (retention or DeleteSnapshot: markDeleting needs no live claim); an *)
|
||||
(* unnamed deleting attempt stays a root until Grace after its delete mark *)
|
||||
(* (gc_copy.go:172-181). A GC mark visits the volumes in ListVolumes order *)
|
||||
(* (F before P), one step per volume, within MD ticks of its start. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, TLC
|
||||
|
||||
CONSTANTS G, MD, MaxT
|
||||
|
||||
VARIABLES t, mst, mdel, fork, gc, cand, deleted
|
||||
vars == <<t, mst, mdel, fork, gc, cand, deleted>>
|
||||
|
||||
Init == /\ t = 0 /\ mst = "active" /\ mdel = 0
|
||||
/\ fork = "idle" \* idle -> claimed -> intent -> headed -> done
|
||||
/\ gc = [st |-> "idle", start |-> 0, seenF |-> FALSE]
|
||||
/\ cand = -1 /\ deleted = FALSE
|
||||
|
||||
Tick == t < MaxT /\ t' = t + 1 /\ UNCHANGED <<mst, mdel, fork, gc, cand, deleted>>
|
||||
ForkStep == /\ fork # "done" /\ mst = "active"
|
||||
/\ fork' = CASE fork = "idle" -> "claimed" [] fork = "claimed" -> "intent"
|
||||
[] fork = "intent" -> "headed" [] OTHER -> "done"
|
||||
/\ UNCHANGED <<t, mst, mdel, gc, cand, deleted>>
|
||||
\* M deleted once no live claim holds it (claim live until F's HEAD exists)
|
||||
DeleteM == /\ mst = "active" /\ fork \in {"idle", "headed", "done"}
|
||||
/\ mst' = "deleting" /\ mdel' = t
|
||||
/\ UNCHANGED <<t, fork, gc, cand, deleted>>
|
||||
|
||||
RootF == fork \in {"intent", "headed", "done"} \* F's intent, then F's HEAD
|
||||
RootP == mst = "active" \/ (mst = "deleting" /\ t - mdel <= G)
|
||||
|
||||
MarkF == gc.st = "idle" /\ gc' = [st |-> "F", start |-> t, seenF |-> RootF] /\ UNCHANGED <<t, mst, mdel, fork, cand, deleted>>
|
||||
MarkP == /\ gc.st = "F" /\ t - gc.start <= MD
|
||||
/\ LET rooted == gc.seenF \/ RootP IN
|
||||
IF rooted THEN cand' = -1 /\ deleted' = deleted
|
||||
ELSE IF cand >= 0 /\ gc.start - cand >= G THEN deleted' = TRUE /\ cand' = cand
|
||||
ELSE cand' = (IF cand >= 0 THEN cand ELSE gc.start) /\ deleted' = deleted
|
||||
/\ gc' = [st |-> "idle", start |-> 0, seenF |-> FALSE]
|
||||
/\ UNCHANGED <<t, mst, mdel, fork>>
|
||||
\* a mark that overran MD is discarded (no coverage)
|
||||
MarkVoid == /\ gc.st = "F" /\ t - gc.start > MD
|
||||
/\ gc' = [st |-> "idle", start |-> 0, seenF |-> FALSE] /\ cand' = -1
|
||||
/\ UNCHANGED <<t, mst, mdel, fork, deleted>>
|
||||
|
||||
Next == Tick \/ ForkStep \/ DeleteM \/ MarkF \/ MarkP \/ MarkVoid
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
\* GC never deletes k while F's HEAD (or intent) or an unexpired M names it
|
||||
NoLiveDelete == deleted => ~(RootF \/ RootP)
|
||||
W_Delete == ~deleted
|
||||
=============================================================================
|
||||
@@ -0,0 +1,72 @@
|
||||
-------------------------- MODULE RetentionGCTiming --------------------------
|
||||
(***************************************************************************)
|
||||
(* S9 (first slice): GC timing with an explicit clock (grace rule). *)
|
||||
(* One snapshot/fork copy operation reads HEAD at t0 (chunk k is rooted by *)
|
||||
(* HEAD), may write its copy intent naming k at any time before its *)
|
||||
(* deadline t0 + D, and publishes before the deadline or refuses *)
|
||||
(* (catalog.go:891-899). The host may drop k from HEAD at any time. *)
|
||||
(* GC runs marks that take up to MD ticks: per volume it reads HEAD and *)
|
||||
(* snapshots first and lists intents last (gc.go:157, 162, 179, 188). A *)
|
||||
(* chunk *)
|
||||
(* is deleted only when unrooted at a mark whose start is >= Grace after *)
|
||||
(* the start of the first mark that saw it unrooted (two-mark rule, *)
|
||||
(* gc.go:262-300). The code refuses Grace <= deadline (gc.go:89) and a *)
|
||||
(* mark with duration + deadline >= Grace (gc.go:255). *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, TLC
|
||||
|
||||
CONSTANTS D, G, MD, MaxT,
|
||||
MarkGuard \* TRUE (code): a mark whose duration + D >= G is discarded (gc.go:255)
|
||||
|
||||
VARIABLES t, headHasK, op, gc, cand, deleted, published
|
||||
vars == <<t, headHasK, op, gc, cand, deleted, published>>
|
||||
|
||||
Init == /\ t = 0 /\ headHasK = TRUE
|
||||
/\ op = [st |-> "idle", t0 |-> 0]
|
||||
/\ gc = [st |-> "idle", start |-> 0, sawRoot |-> FALSE]
|
||||
/\ cand = -1 \* start of the first mark that saw k unrooted (-1: none)
|
||||
/\ deleted = FALSE /\ published = FALSE
|
||||
|
||||
Tick == t < MaxT /\ t' = t + 1 /\ UNCHANGED <<headHasK, op, gc, cand, deleted, published>>
|
||||
\* the host's next cut drops k from HEAD
|
||||
Drop == headHasK /\ headHasK' = FALSE /\ UNCHANGED <<t, op, gc, cand, deleted, published>>
|
||||
|
||||
\* the copy op reads HEAD (k is a root while it is in HEAD)
|
||||
OpRead == op.st = "idle" /\ headHasK /\ op' = [st |-> "read", t0 |-> t] /\ UNCHANGED <<t, headHasK, gc, cand, deleted, published>>
|
||||
OpIntent == op.st = "read" /\ t < op.t0 + D /\ op' = [op EXCEPT !.st = "intent"] /\ UNCHANGED <<t, headHasK, gc, cand, deleted, published>>
|
||||
\* deadline re-checked immediately before the publish; the snapshot then roots k
|
||||
OpPublish == op.st = "intent" /\ t < op.t0 + D
|
||||
/\ op' = [op EXCEPT !.st = "done"] /\ published' = TRUE
|
||||
/\ UNCHANGED <<t, headHasK, gc, cand, deleted>>
|
||||
OpRefuse == op.st \in {"read", "intent"} /\ t >= op.t0 + D
|
||||
/\ op' = [op EXCEPT !.st = "refused"] /\ UNCHANGED <<t, headHasK, gc, cand, deleted, published>>
|
||||
|
||||
IntentRoot == op.st = "intent"
|
||||
SnapRoot == published
|
||||
|
||||
\* mark: (1) read HEAD and snapshots ...
|
||||
MarkStart == gc.st = "idle" /\ gc' = [st |-> "listed", start |-> t, sawRoot |-> headHasK \/ SnapRoot]
|
||||
/\ UNCHANGED <<t, headHasK, op, cand, deleted, published>>
|
||||
\* ... (2) list intents, at most MD ticks later; decide k
|
||||
MarkEnd == /\ gc.st = "listed"
|
||||
/\ LET rooted == gc.sawRoot \/ IntentRoot
|
||||
late == t - gc.start > MD \* the mark took longer than MD
|
||||
void == late \/ (MarkGuard /\ (t - gc.start) + D >= G)
|
||||
IN IF void
|
||||
THEN /\ cand' = -1 /\ deleted' = deleted \* a failed mark discards coverage
|
||||
ELSE IF rooted
|
||||
THEN /\ cand' = -1 /\ deleted' = deleted
|
||||
ELSE IF cand >= 0 /\ gc.start - cand >= G
|
||||
THEN /\ deleted' = TRUE /\ cand' = cand
|
||||
ELSE /\ cand' = (IF cand >= 0 THEN cand ELSE gc.start) /\ deleted' = deleted
|
||||
/\ gc' = [st |-> "idle", start |-> 0, sawRoot |-> FALSE]
|
||||
/\ UNCHANGED <<t, headHasK, op, published>>
|
||||
|
||||
Next == Tick \/ Drop \/ OpRead \/ OpIntent \/ OpPublish \/ OpRefuse \/ MarkStart \/ MarkEnd
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
\* GC never deletes a chunk that a published snapshot, an intent, or HEAD names
|
||||
NoLiveDelete == deleted => ~(published \/ IntentRoot \/ headHasK)
|
||||
W_Publish == ~published
|
||||
W_Delete == ~deleted
|
||||
=============================================================================
|
||||
@@ -0,0 +1,156 @@
|
||||
-------------------------- MODULE SmartWALRecovery --------------------------
|
||||
(***************************************************************************)
|
||||
(* S3, smartwal layout (core/storage/smartwal at 5c293821): data is *)
|
||||
(* written IN PLACE to the extent block of its LBA, then a metadata record *)
|
||||
(* {lsn, lba, crc of the data, durable_lsn} goes to ring slot lsn mod C *)
|
||||
(* (store.go:266-288, ring.go:45-55). Sync is one fsync (store.go:314-331).*)
|
||||
(* Unsynced extent blocks and ring slots are written back in ARBITRARY *)
|
||||
(* order; a slot may also be written back TORN (magic intact, bad CRC). *)
|
||||
(* Crash at any point, optionally with ONE durable extent block or ring *)
|
||||
(* slot corrupted. Recovery may run twice: after the first recovery the *)
|
||||
(* store continues, may AdvanceFrontier (an in-memory jump that writes no *)
|
||||
(* slots), writes, syncs and crashes again (a schedule from review of *)
|
||||
(* PR #155). *)
|
||||
(* Each write has a unique issue number `ts` that stands for its data/CRC. *)
|
||||
(* *)
|
||||
(* Rule: *)
|
||||
(* "current" runRecovery (recovery.go:39-110): valid slots only (a bad *)
|
||||
(* CRC is skipped as torn, ring.go:62-82); per LBA the *)
|
||||
(* highest-LSN record; extent must match its crc else fail *)
|
||||
(* closed (85d93753); frontier = max verified LSN. *)
|
||||
(* "holeFail" also fail closed on any missing LSN in the window below Hi.*)
|
||||
(* "pr155" PR #155 at 089d2d9: a torn slot is a mid-history hole *)
|
||||
(* (wal_corrupt) unless it is the slot right after the highest*)
|
||||
(* valid LSN; its LSN is inferred from its position. *)
|
||||
(* "pr155o" the pr155 torn-slot rule alone (extent mismatches are not *)
|
||||
(* judged), to isolate the positional inference (a schedule *)
|
||||
(* from review of PR #155). *)
|
||||
(* "watermark" W = max durable_lsn over valid records; a missing LSN *)
|
||||
(* <= W not covered by a gap marker, or an extent mismatch at *)
|
||||
(* a record <= W, fails closed; above W it is a torn tail. *)
|
||||
(* "ordered" watermark, and the record is durable before the data write.*)
|
||||
(* Marker: AdvanceFrontier persists a gap record covering the skipped LSNs.*)
|
||||
(* Repair: before the store continues, recovery durably replaces every *)
|
||||
(* slot it treated as a torn tail (torn, or any record above W of *)
|
||||
(* an LBA whose extent mismatches) with a gap record for that LSN, *)
|
||||
(* re-attests the last record of such an LBA with the CRC of the *)
|
||||
(* bytes the extent holds, and the frontier is max(W, verified and *)
|
||||
(* attested last writers), so a later *)
|
||||
(* watermark cannot reclassify it as corruption. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS C, MaxLSN, LBAs, Rule, CorruptOn, MaxTs, Jump, Marker, Rounds, Repair, CorruptExtent
|
||||
|
||||
NoRec == [k |-> "zero", lsn |-> 0, lo |-> 0, lba |-> "-", crc |-> 0, dl |-> 0]
|
||||
Slots == 0..(C - 1)
|
||||
Pgs == {<<"e", l>> : l \in LBAs} \cup {<<"r", s>> : s \in Slots}
|
||||
Ordered == Rule = "ordered"
|
||||
|
||||
VARIABLES cache, disk, nxt, ts, synced, pend, lastSynced, phase, corrupt, round, res
|
||||
vars == <<cache, disk, nxt, ts, synced, pend, lastSynced, phase, corrupt, round, res>>
|
||||
|
||||
Init == /\ cache = [p \in Pgs |-> IF p[1] = "e" THEN 0 ELSE NoRec]
|
||||
/\ disk = cache
|
||||
/\ nxt = 1 /\ ts = 0 /\ synced = 0
|
||||
/\ pend = [l \in LBAs |-> 0] /\ lastSynced = [l \in LBAs |-> 0]
|
||||
/\ phase = "run" /\ corrupt = <<"-", "-">> /\ round = 1
|
||||
/\ res = [failed |-> FALSE, state |-> [l \in LBAs |-> 0], frontier |-> 0, everCorrupt |-> FALSE]
|
||||
|
||||
Write(l) == /\ phase = "run" /\ nxt <= MaxLSN /\ ts < MaxTs
|
||||
/\ LET r == [k |-> "rec", lsn |-> nxt, lo |-> nxt, lba |-> l, crc |-> ts + 1, dl |-> synced]
|
||||
IN /\ cache' = [cache EXCEPT ![<<"e", l>>] = ts + 1, ![<<"r", nxt % C>>] = r]
|
||||
/\ disk' = IF Ordered THEN [disk EXCEPT ![<<"r", nxt % C>>] = r] ELSE disk
|
||||
/\ nxt' = nxt + 1 /\ ts' = ts + 1
|
||||
/\ pend' = [pend EXCEPT ![l] = ts + 1]
|
||||
/\ UNCHANGED <<synced, lastSynced, phase, corrupt, round, res>>
|
||||
|
||||
\* in-memory frontier jump (no slots written); with Marker a gap record covering
|
||||
\* the skipped LSNs goes to the slot of the last skipped LSN
|
||||
Advance == /\ phase = "run" /\ round > 1 /\ nxt + Jump <= MaxLSN
|
||||
/\ cache' = IF Marker
|
||||
THEN [cache EXCEPT ![<<"r", (nxt + Jump - 1) % C>>] =
|
||||
[k |-> "gap", lsn |-> nxt + Jump - 1, lo |-> nxt, lba |-> "-", crc |-> 0, dl |-> synced]]
|
||||
ELSE cache
|
||||
/\ nxt' = nxt + Jump
|
||||
/\ UNCHANGED <<disk, ts, synced, pend, lastSynced, phase, corrupt, round, res>>
|
||||
|
||||
Writeback == /\ phase = "run"
|
||||
/\ \E p \in Pgs : /\ cache[p] # disk[p]
|
||||
/\ \/ disk' = [disk EXCEPT ![p] = cache[p]]
|
||||
\/ p[1] = "r" /\ disk' = [disk EXCEPT ![p] = [NoRec EXCEPT !.k = "torn"]]
|
||||
/\ UNCHANGED <<cache, nxt, ts, synced, pend, lastSynced, phase, corrupt, round, res>>
|
||||
|
||||
Sync == /\ phase = "run" /\ (cache # disk \/ synced < nxt - 1)
|
||||
/\ disk' = cache /\ synced' = nxt - 1
|
||||
/\ lastSynced' = pend
|
||||
/\ UNCHANGED <<cache, nxt, ts, pend, phase, corrupt, round, res>>
|
||||
|
||||
Crash == /\ phase = "run" /\ phase' = "crashed"
|
||||
/\ \/ corrupt' = <<"-", "-">>
|
||||
\/ CorruptOn /\ \E p \in Pgs : (IF p[1] = "e" THEN CorruptExtent ELSE disk[p].k = "rec") /\ corrupt' = p
|
||||
/\ UNCHANGED <<cache, disk, nxt, ts, synced, pend, lastSynced, round, res>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Max(S) == IF S = {} THEN 0 ELSE CHOOSE m \in S : \A s \in S : s <= m
|
||||
SlotOK(s) == disk[<<"r", s>>].k \in {"rec", "gap"} /\ corrupt # <<"r", s>>
|
||||
Valid == {disk[<<"r", s>>] : s \in {t \in Slots : SlotOK(t) /\ disk[<<"r", t>>].k = "rec"}}
|
||||
Gaps == {disk[<<"r", s>>] : s \in {t \in Slots : SlotOK(t) /\ disk[<<"r", t>>].k = "gap"}}
|
||||
Torn == {s \in Slots : disk[<<"r", s>>].k = "torn" \/ corrupt = <<"r", s>>}
|
||||
Covered == UNION {g.lo..g.lsn : g \in Gaps}
|
||||
ExtentVal(l) == IF corrupt = <<"e", l>> THEN -1 ELSE disk[<<"e", l>>]
|
||||
Last(l) == LET mine == {r \in Valid : r.lba = l}
|
||||
IN IF mine = {} THEN NoRec ELSE CHOOSE r \in mine : \A q \in mine : q.lsn <= r.lsn
|
||||
Hi == Max({r.lsn : r \in Valid} \cup {g.lsn : g \in Gaps})
|
||||
Window == (IF Hi > C THEN Hi - C + 1 ELSE 1)..Hi
|
||||
Present == {r.lsn : r \in Valid} \cup Covered
|
||||
Missing == {n \in Window : n \notin Present}
|
||||
\* positional LSN of a slot relative to Hi (PR #155 revision 089d2d9, smartwal/recovery.go:122)
|
||||
Implied(s) == Hi - ((Hi - s) % C)
|
||||
W == Max({r.dl : r \in Valid} \cup {g.dl : g \in Gaps})
|
||||
|
||||
Recover ==
|
||||
/\ phase = "crashed"
|
||||
/\ LET mismatch(l) == Last(l) # NoRec /\ ExtentVal(l) # Last(l).crc
|
||||
tornMid == \E s \in Torn : (Hi - s) % C # C - 1 /\ Implied(s) >= 1 /\ Implied(s) \notin Covered
|
||||
failed == CASE Rule = "current" -> \E l \in LBAs : mismatch(l)
|
||||
[] Rule = "holeFail" -> (\E l \in LBAs : mismatch(l)) \/ Missing # {}
|
||||
[] Rule \in {"pr155", "pr155o"} -> (\E l \in LBAs : mismatch(l) /\ Rule = "pr155") \/ tornMid
|
||||
[] OTHER -> \/ \E l \in LBAs : mismatch(l) /\ Last(l).lsn <= W
|
||||
\/ \E n \in Missing : n <= W
|
||||
verified == {Last(l).lsn : l \in {m \in LBAs : Last(m) # NoRec /\ ~mismatch(m)}}
|
||||
\* "current" keeps the code's frontier (max verified last-writer, recovery.go:96);
|
||||
\* the proposals count every valid record that is not a torn tail, and W
|
||||
good == {r.lsn : r \in {q \in Valid : ~\E l \in LBAs : mismatch(l) /\ Last(l) = q}}
|
||||
attested == IF Repair THEN {Last(l).lsn : l \in {m \in LBAs : mismatch(m) /\ Last(m).lsn > W}} ELSE {}
|
||||
fr == IF Rule \in {"watermark", "ordered"} THEN Max(verified \cup Covered \cup {W} \cup attested) ELSE Max(verified \cup Covered)
|
||||
IN /\ res' = [failed |-> failed, state |-> [l \in LBAs |-> ExtentVal(l)], frontier |-> fr,
|
||||
everCorrupt |-> res.everCorrupt \/ corrupt # <<"-", "-">>]
|
||||
\* the store continues from the recovered image (store.go:179-201): nextLSN = frontier+1
|
||||
/\ IF ~failed /\ round < Rounds
|
||||
THEN /\ phase' = "run" /\ round' = round + 1
|
||||
/\ LET settled(q) == Repair /\ q[1] = "r" /\ (q[2] \in Torn \/ (disk[q].k = "rec" /\ disk[q].lsn > W /\ mismatch(disk[q].lba)))
|
||||
img == [p \in Pgs |-> IF p[1] = "e" THEN ExtentVal(p[2])
|
||||
ELSE IF settled(p) /\ disk[p].k = "rec" /\ Last(disk[p].lba) = disk[p] /\ ExtentVal(disk[p].lba) >= 0
|
||||
\* re-attest the bytes the extent now holds (the accepted torn tail)
|
||||
THEN [disk[p] EXCEPT !.crc = ExtentVal(disk[p].lba), !.dl = W]
|
||||
ELSE IF settled(p) THEN [k |-> "gap", lsn |-> Implied(p[2]), lo |-> Implied(p[2]), lba |-> "-", crc |-> 0, dl |-> W]
|
||||
ELSE disk[p]]
|
||||
IN /\ cache' = img /\ disk' = img
|
||||
/\ nxt' = fr + 1 /\ synced' = fr
|
||||
/\ pend' = [l \in LBAs |-> ExtentVal(l)] /\ lastSynced' = [l \in LBAs |-> ExtentVal(l)]
|
||||
/\ corrupt' = <<"-", "-">>
|
||||
ELSE /\ phase' = "recovered"
|
||||
/\ UNCHANGED <<cache, disk, nxt, synced, pend, lastSynced, round, corrupt>>
|
||||
/\ UNCHANGED <<ts>>
|
||||
|
||||
Next == (\E l \in LBAs : Write(l)) \/ Advance \/ Writeback \/ Sync \/ Crash \/ Recover
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
\* checked after the final recovery (state = what the volume would serve)
|
||||
I1 == phase = "recovered" => (res.failed \/ \A l \in LBAs : res.state[l] >= lastSynced[l])
|
||||
I1Frontier == phase = "recovered" => (res.failed \/ res.frontier >= synced)
|
||||
I2 == (phase = "recovered" /\ ~res.everCorrupt /\ corrupt = <<"-", "-">>) => ~res.failed
|
||||
W_NoRecovery == ~(phase = "recovered" /\ ~res.failed /\ round = Rounds /\ synced >= 2)
|
||||
=============================================================================
|
||||
@@ -0,0 +1,256 @@
|
||||
----------------------------- MODULE WALRecovery -----------------------------
|
||||
(***************************************************************************)
|
||||
(* S3, walstore layout: a ring WAL of K pages in front of an extent. *)
|
||||
(* Records of 1 or 2 pages are appended to the page cache, written back to *)
|
||||
(* the durable image page by page in ARBITRARY order, and made durable as *)
|
||||
(* a whole by Sync. The flusher checkpoints the oldest record into the *)
|
||||
(* extent and persists the superblock {tail, head, checkpoint}. Then the *)
|
||||
(* host crashes at any point, optionally with ONE durable record page *)
|
||||
(* corrupted, and recovery runs once. *)
|
||||
(* *)
|
||||
(* Rule selects recovery: *)
|
||||
(* "current" core/storage/recovery.go recoverWAL at 5c293821: scan *)
|
||||
(* each physical range, stop the RANGE at the first decode *)
|
||||
(* failure, continue with the next range, replay all. *)
|
||||
(* "holeFail" fail closed when any LSN in (checkpoint, max] is missing.*)
|
||||
(* "pr155" PR #155 at 089d2d9 (walstore, warning-only): every range *)
|
||||
(* that stops on a bad entry cuts replay at its decoded *)
|
||||
(* predecessor + 1 (default checkpoint + 1); scan-order replay.*)
|
||||
(* "watermark" each record carries durable_lsn (highest LSN whose Sync *)
|
||||
(* had completed when it was written). W = max over valid *)
|
||||
(* records. Contiguous prefix R from checkpoint: R < W -> *)
|
||||
(* fail closed; else replay only up to R (never past a hole).*)
|
||||
(* "watermarkSB" as watermark, plus Sync persists W in the superblock *)
|
||||
(* (second fsync) before it returns. *)
|
||||
(* "watermarkFull" watermarkSB, and recovery decodes every page position *)
|
||||
(* instead of stopping a range at its first bad entry. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS K, MaxLSN, LBAs, Rule, CorruptOn, MaxCkpt,
|
||||
CkptLag, \* TRUE (code): persistCheckpoint writes the PRE-advance tail (walstore.go:402-405, flusher.go:223-227)
|
||||
ReuseBound, \* "mem" (code): the writer reuses space released by the in-memory tail; "persisted": root fix
|
||||
JumpOn, \* an AdvanceFrontier / BASE jump (in memory; persisted by the next Sync, walstore.go:866-898)
|
||||
JumpPersistedBySync, \* TRUE: Sync persists the pending jump before it acknowledges; FALSE: the
|
||||
\* rebuild path (AdvanceFrontier stays in memory until MarkBaseComplete + Sync)
|
||||
Forge \* a 2-page record's payload page may carry bytes that decode as a valid record
|
||||
|
||||
Zero == [k |-> "zero", lsn |-> 0, part |-> 0, size |-> 0, lba |-> "-", dl |-> 0, fake |-> FALSE]
|
||||
Pad == [k |-> "pad", lsn |-> 0, part |-> 0, size |-> 0, lba |-> "-", dl |-> 0, fake |-> FALSE]
|
||||
Pages == 0..(K - 1)
|
||||
|
||||
VARIABLES
|
||||
memTail, pendJ, syncing, \* in-memory tail; pending jump LSN; LSNs a Sync made durable but not yet acked
|
||||
cache, disk, \* page cache and durable image of the WAL pages
|
||||
recs, \* appended records, in LSN order: [lsn, lba, start (logical), size, dl]
|
||||
head, \* in-memory logical head (next page)
|
||||
synced, \* highest LSN whose Sync completed (acknowledged durable)
|
||||
sb, \* durable superblock [tail, head, ckpt, w]
|
||||
extent, \* durable extent: lba -> LSN of the write it holds (0 = never)
|
||||
phase, corrupt, \* "run" | "crashed" | "recovered"; corrupted page or -1
|
||||
res \* recovery result [failed, state (lba -> lsn), replayed (set of LSN)]
|
||||
|
||||
vars == <<memTail, pendJ, syncing, cache, disk, recs, head, synced, sb, extent, phase, corrupt, res>>
|
||||
|
||||
NextLSN == Len(recs) + 1
|
||||
|
||||
Init == /\ memTail = 0 /\ pendJ = 0 /\ syncing = 0
|
||||
/\ cache = [p \in Pages |-> Zero] /\ disk = [p \in Pages |-> Zero]
|
||||
/\ recs = <<>> /\ head = 0 /\ synced = 0
|
||||
/\ sb = [tail |-> 0, head |-> 0, ckpt |-> 0, w |-> 0]
|
||||
/\ extent = [l \in LBAs |-> 0]
|
||||
/\ phase = "run" /\ corrupt = -1
|
||||
/\ res = [failed |-> FALSE, state |-> [l \in LBAs |-> 0], replayed |-> {}, forged |-> FALSE, lastWriter |-> [l \in LBAs |-> 0]]
|
||||
|
||||
\* WAL append (walstore.go write path -> wal append): a 2-page record never
|
||||
\* straddles the physical end; the remainder is padded and it starts the next lap.
|
||||
AppendRec(l, sz) ==
|
||||
/\ phase = "run" /\ NextLSN <= MaxLSN
|
||||
/\ LET p == head % K
|
||||
padN == IF p + sz > K THEN K - p ELSE 0
|
||||
st == head + padN
|
||||
rec(i) == [k |-> "rec", lsn |-> NextLSN, part |-> i, size |-> sz, lba |-> l, dl |-> synced, fake |-> FALSE]
|
||||
IN /\ st + sz - (IF ReuseBound = "persisted" THEN sb.tail ELSE memTail) <= K \* ring space
|
||||
/\ cache' = [q \in Pages |->
|
||||
IF padN > 0 /\ q >= p THEN Pad
|
||||
ELSE IF q = st % K THEN rec(1)
|
||||
ELSE IF sz = 2 /\ q = (st + 1) % K THEN (IF Forge THEN [rec(2) EXCEPT !.fake = TRUE] ELSE rec(2))
|
||||
ELSE cache[q]]
|
||||
/\ recs' = Append(recs, [lsn |-> NextLSN, lba |-> l, start |-> st, size |-> sz, dl |-> synced, jump |-> FALSE])
|
||||
/\ head' = st + sz
|
||||
/\ UNCHANGED <<memTail, pendJ, syncing, disk, synced, sb, extent, phase, corrupt, res>>
|
||||
|
||||
\* AdvanceFrontier (walstore.go AdvanceFrontier): skip one LSN without writing it; the jump is
|
||||
\* recorded in memory and persisted as the checkpoint by the next Sync (when JumpPersistedBySync)
|
||||
JumpFrontier == /\ JumpOn /\ phase = "run" /\ NextLSN <= MaxLSN /\ pendJ = 0 /\ sb.ckpt = Len(recs)
|
||||
/\ recs' = Append(recs, [lsn |-> NextLSN, lba |-> "-", start |-> head, size |-> 0, dl |-> synced, jump |-> TRUE])
|
||||
/\ pendJ' = NextLSN
|
||||
/\ UNCHANGED <<memTail, syncing, cache, disk, head, synced, sb, extent, phase, corrupt, res>>
|
||||
|
||||
\* the kernel writes one dirty page back, in any order
|
||||
Writeback == /\ phase = "run"
|
||||
/\ \E p \in Pages : /\ cache[p] # disk[p] /\ disk' = [disk EXCEPT ![p] = cache[p]]
|
||||
/\ UNCHANGED <<memTail, pendJ, syncing, cache, recs, head, synced, sb, extent, phase, corrupt, res>>
|
||||
|
||||
\* Sync, step 1: fsync of the WAL pages (durable, not yet acknowledged)
|
||||
Sync == /\ phase = "run" /\ synced < Len(recs) /\ syncing = 0
|
||||
/\ disk' = cache /\ syncing' = Len(recs)
|
||||
/\ UNCHANGED <<memTail, pendJ, cache, recs, head, synced, sb, extent, phase, corrupt, res>>
|
||||
\* Sync, step 2: the second fsync (superblock: pending jump as checkpoint, head; W for the
|
||||
\* watermark rules), then the acknowledgement (walstore.go:866-905)
|
||||
SyncAck == /\ phase = "run" /\ syncing > 0
|
||||
/\ LET j == JumpPersistedBySync /\ pendJ > sb.ckpt /\ pendJ <= syncing
|
||||
w == Rule \in {"watermarkSB", "watermarkFull", "prefixFullSB"}
|
||||
IN /\ sb' = [sb EXCEPT !.ckpt = IF j THEN pendJ ELSE @, !.head = IF j THEN head ELSE @,
|
||||
!.w = IF w THEN syncing ELSE @]
|
||||
/\ pendJ' = IF j THEN 0 ELSE pendJ
|
||||
/\ synced' = syncing /\ syncing' = 0
|
||||
/\ UNCHANGED <<memTail, cache, disk, recs, head, extent, phase, corrupt, res>>
|
||||
|
||||
\* flusher: apply the oldest retained record to the extent, fsync it, then
|
||||
\* persist the superblock (tail past it, current head, checkpoint LSN)
|
||||
Checkpoint == /\ phase = "run" /\ sb.ckpt < Len(recs) /\ sb.ckpt < MaxCkpt
|
||||
/\ LET r == recs[sb.ckpt + 1]
|
||||
end == IF r.jump THEN memTail ELSE r.start + r.size
|
||||
IN /\ extent' = IF r.jump THEN extent ELSE [extent EXCEPT ![r.lba] = r.lsn]
|
||||
\* persistCheckpoint writes {ckpt, live head, tail}; with CkptLag the tail is the
|
||||
\* PRE-advance one and the in-memory tail advances afterwards
|
||||
/\ sb' = [sb EXCEPT !.tail = IF CkptLag THEN memTail ELSE end, !.head = head, !.ckpt = r.lsn]
|
||||
/\ memTail' = end
|
||||
/\ pendJ' = IF r.jump THEN 0 ELSE pendJ
|
||||
/\ UNCHANGED <<syncing, cache, disk, recs, head, synced, phase, corrupt, res>>
|
||||
|
||||
Crash == /\ phase = "run" /\ phase' = "crashed"
|
||||
/\ \/ corrupt' = -1
|
||||
\/ CorruptOn /\ \E p \in Pages : disk[p].k = "rec" /\ corrupt' = p
|
||||
/\ UNCHANGED <<memTail, pendJ, syncing, cache, disk, recs, head, synced, sb, extent, res>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* recovery *)
|
||||
|
||||
Bad(p) == p = corrupt
|
||||
\* a valid record whose first page is at physical p, inside [p, e)
|
||||
Forged(p) == disk[p].k = "rec" /\ disk[p].part = 2 /\ disk[p].fake /\ ~Bad(p)
|
||||
FakeRec(p) == [k |-> "rec", lsn |-> disk[p].lsn + 1, part |-> 1, size |-> 1, lba |-> "y", dl |-> disk[p].dl, fake |-> TRUE]
|
||||
View(p) == IF Forged(p) THEN FakeRec(p) ELSE disk[p]
|
||||
ValidAt0(p, e) ==
|
||||
/\ disk[p].k = "rec" /\ disk[p].part = 1 /\ ~Bad(p)
|
||||
/\ disk[p].size = 2 => (p + 1 < e /\ disk[p + 1].k = "rec" /\ disk[p + 1].part = 2
|
||||
/\ disk[p + 1].lsn = disk[p].lsn /\ ~Bad(p + 1))
|
||||
ValidAt(p, e) == Forged(p) \/ ValidAt0(p, e)
|
||||
|
||||
\* scan [pos, e) (recovery.go:96-206): the records decoded in scan order, and
|
||||
\* whether the range stopped on a BAD entry (torn or corrupt; trailing zeros are
|
||||
\* not bad) together with the LSN of its decoded predecessor in the range
|
||||
\* (pred starts at the checkpoint, as #155 does at recovery.go:201 of 089d2d9)
|
||||
RECURSIVE Scan(_, _, _)
|
||||
Scan(pos, e, pred) ==
|
||||
IF pos >= e THEN [recs |-> <<>>, bad |-> FALSE, pred |-> pred]
|
||||
ELSE IF disk[pos].k = "pad" THEN Scan(pos + 1, e, pred)
|
||||
ELSE IF ValidAt(pos, e)
|
||||
THEN LET r == Scan(pos + View(pos).size, e, View(pos).lsn)
|
||||
IN [r EXCEPT !.recs = <<View(pos)>> \o @]
|
||||
ELSE [recs |-> <<>>, bad |-> disk[pos].k # "zero", pred |-> pred]
|
||||
|
||||
\* physical ranges from the superblock (recovery.go:57-93). For head == tail the
|
||||
\* code walks record footers backward from the physical end to find the start
|
||||
\* of the high run (findDefensiveHighRunStart, recovery.go:250-283, and
|
||||
\* previousValidWALRecord); a 1-page footer stands for the size field.
|
||||
PrevStart(c) ==
|
||||
IF c >= 1 /\ disk[c - 1].k = "pad" THEN c - 1
|
||||
ELSE IF c >= 1 /\ disk[c - 1].k = "rec" /\ disk[c - 1].part = 1 /\ disk[c - 1].size = 1 /\ ValidAt(c - 1, K) THEN c - 1
|
||||
ELSE IF c >= 2 /\ disk[c - 1].k = "rec" /\ disk[c - 1].part = 2 /\ disk[c - 2].size = 2 /\ disk[c - 2].lsn = disk[c - 1].lsn /\ ValidAt(c - 2, K) THEN c - 2
|
||||
ELSE -1
|
||||
RECURSIVE Walk(_, _, _)
|
||||
Walk(c, earliest, data) == LET p == PrevStart(c)
|
||||
IN IF p < 0 THEN [e |-> earliest, data |-> data]
|
||||
ELSE Walk(p, p, data \/ disk[p].k = "rec")
|
||||
HighRun == LET w == Walk(K, K, FALSE) IN IF w.data /\ w.e > 0 /\ w.e < K THEN w.e ELSE 0
|
||||
DefStarts == {HighRun}
|
||||
RangesFrom(ds) ==
|
||||
LET pH == sb.head % K
|
||||
pT == sb.tail % K
|
||||
IN IF sb.head = sb.tail /\ Rule = "rootLww" /\ pH # 0 THEN <<<<pH, K>>, <<0, pH>>, <<0, 0>>>> \* #159
|
||||
ELSE IF sb.head = sb.tail THEN <<<<ds, K>>, <<0, ds>>, <<0, 0>>>>
|
||||
ELSE IF pH > pT THEN <<<<pT, pH>>, <<pH, K>>, <<0, pT>>>>
|
||||
ELSE <<<<pT, K>>, <<0, pH>>, <<pH, pT>>>>
|
||||
|
||||
Scans(ds) == LET r == RangesFrom(ds) IN [i \in 1..3 |-> Scan(r[i][1], r[i][2], sb.ckpt)]
|
||||
\* retained records in scan order (LSN above the checkpoint)
|
||||
\* "watermarkFull": every page position is decoded on its own (records are
|
||||
\* self-checking), so no range break can hide a durable record
|
||||
FullSeq == LET ps == {p \in Pages : ValidAt(p, K) /\ disk[p].lsn > sb.ckpt}
|
||||
RECURSIVE Build(_)
|
||||
Build(S) == IF S = {} THEN <<>> ELSE LET m == CHOOSE x \in S : \A y \in S : x <= y
|
||||
IN <<View(m)>> \o Build(S \ {m})
|
||||
IN Build(ps)
|
||||
FoundSeq(ds) == IF Rule \in {"watermarkFull", "lwwFull", "prefixFull", "prefixFullSB"} THEN FullSeq ELSE LET s == Scans(ds)
|
||||
all == s[1].recs \o s[2].recs \o s[3].recs
|
||||
IN SelectSeq(all, LAMBDA f : f.lsn > sb.ckpt)
|
||||
|
||||
Max(S) == IF S = {} THEN 0 ELSE CHOOSE m \in S : \A s \in S : s <= m
|
||||
Min(S) == CHOOSE m \in S : \A s \in S : m <= s
|
||||
SeqSet(q) == {q[i] : i \in 1..Len(q)}
|
||||
RECURSIVE PrefixIn(_, _)
|
||||
PrefixIn(n, L) == IF n + 1 \in L THEN PrefixIn(n + 1, L) ELSE n
|
||||
|
||||
\* replay into the dirty map: scan order, unconditional replace (recovery.go:158-190,
|
||||
\* dirty_map.go putAt) for "current"/"holeFail"/"pr155"; by LSN for the watermark rules
|
||||
RECURSIVE FoldScan(_, _, _)
|
||||
FoldScan(q, i, st) == IF i > Len(q) THEN st ELSE FoldScan(q, i + 1, [st EXCEPT ![q[i].lba] = q[i].lsn])
|
||||
ByLSN(F) == [l \in LBAs |-> LET mine == {f.lsn : f \in {g \in F : g.lba = l}}
|
||||
IN IF mine = {} THEN extent[l] ELSE Max(mine)]
|
||||
|
||||
Recover ==
|
||||
/\ phase = "crashed"
|
||||
/\ \E ds \in DefStarts :
|
||||
LET q == FoundSeq(ds)
|
||||
F == SeqSet(q)
|
||||
L == {f.lsn : f \in F}
|
||||
R == PrefixIn(sb.ckpt, L)
|
||||
W == Max({f.dl : f \in F} \cup {sb.w})
|
||||
hole == \E n \in (sb.ckpt + 1)..Max(L) : n \notin L
|
||||
sc == Scans(ds)
|
||||
cuts == {sc[i].pred + 1 : i \in {j \in 1..3 : sc[j].bad}}
|
||||
cutoff == IF cuts = {} THEN Max(L) + 1 ELSE Min(cuts)
|
||||
keep == CASE Rule = "pr155" -> SelectSeq(q, LAMBDA f : f.lsn < cutoff)
|
||||
[] Rule \in {"watermark", "watermarkSB", "watermarkFull", "prefixFull", "prefixFullSB"} -> SelectSeq(q, LAMBDA f : f.lsn <= R)
|
||||
[] OTHER -> q
|
||||
failed == CASE Rule = "holeFail" -> hole
|
||||
[] Rule \in {"watermark", "watermarkSB", "watermarkFull", "prefixFullSB"} -> R < W
|
||||
[] OTHER -> FALSE \* current; pr155 is warning-only for walstore
|
||||
st == IF Rule \in {"watermark", "watermarkSB", "watermarkFull", "lww", "lwwFull", "prefixFull", "prefixFullSB", "rootLww"} THEN ByLSN(SeqSet(keep))
|
||||
ELSE FoldScan(keep, 1, extent)
|
||||
IN res' = [failed |-> failed, state |-> st, replayed |-> {f.lsn : f \in SeqSet(keep)},
|
||||
forged |-> \E f \in SeqSet(keep) : f.fake /\ f.part = 1,
|
||||
lastWriter |-> ByLSN(SeqSet(keep))]
|
||||
/\ phase' = "recovered"
|
||||
/\ UNCHANGED <<memTail, pendJ, syncing, cache, disk, recs, head, synced, sb, extent, corrupt>>
|
||||
|
||||
Next == \/ \E l \in LBAs, sz \in {1, 2} : AppendRec(l, sz)
|
||||
\/ Writeback \/ Sync \/ SyncAck \/ Checkpoint \/ JumpFrontier \/ Crash \/ Recover
|
||||
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* I1: every synced write is recovered (or superseded by a later write that is), or recovery fails closed *)
|
||||
I1 == phase = "recovered" =>
|
||||
(res.failed \/ \A i \in 1..synced : recs[i].jump \/ res.state[recs[i].lba] >= recs[i].lsn)
|
||||
(* I2: crash only, no corruption: recovery never reports corruption *)
|
||||
I2 == (phase = "recovered" /\ corrupt = -1) => ~res.failed
|
||||
(* I0Prefix (informational): a successful recovery never replays past a hole *)
|
||||
I0Prefix == (phase = "recovered" /\ ~res.failed) =>
|
||||
\A n \in res.replayed : \A m \in (sb.ckpt + 1)..n : m \in res.replayed
|
||||
|
||||
(* recovery never replays bytes forged inside a user data payload *)
|
||||
NoForgedReplay == (phase = "recovered" /\ ~res.failed) => ~res.forged
|
||||
(* replayed state equals the last writer by LSN among the replayed records (review of #155) *)
|
||||
ReplayLastWriter == (phase = "recovered" /\ ~res.failed) => res.state = res.lastWriter
|
||||
|
||||
\* witnesses (expected violated): recovery succeeds after a wrap with replayed records
|
||||
W_NoWrapRecovery == ~(phase = "recovered" /\ ~res.failed /\ head > K /\ res.replayed # {})
|
||||
W_NoCorruptFailClosed == ~(phase = "recovered" /\ corrupt # -1 /\ res.failed)
|
||||
\* a recovery after a persisted jump that replays a synced record above it
|
||||
W_NoJumpRecovery == ~(phase = "recovered" /\ ~res.failed /\ \E i \in 1..synced : recs[i].jump /\ sb.ckpt >= recs[i].lsn
|
||||
/\ \E k \in (i + 1)..synced : ~recs[k].jump /\ recs[k].lsn \in res.replayed)
|
||||
=============================================================================
|
||||
@@ -0,0 +1,127 @@
|
||||
------------------------------ MODULE WALReplica ------------------------------
|
||||
(***************************************************************************)
|
||||
(* S3 extension: does the synced watermark break replicated mode (RF=2)? *)
|
||||
(* Scope: recovery classification and promotion eligibility only (full *)
|
||||
(* failover is S6). The WAL is abstracted to one slot per LSN (the page *)
|
||||
(* layout is WALRecovery.tla); unsynced slots reach disk in any order. *)
|
||||
(* *)
|
||||
(* Primary P writes locally and ships records in order to replica R; R *)
|
||||
(* writes them to its own WAL and Syncs on its own schedule, then acks. *)
|
||||
(* A write is acknowledged to the client once P synced it and R acked it. *)
|
||||
(* Optionally R joined by BASE rebuild at LSN B (RebaseShipLSN): its WAL *)
|
||||
(* legitimately lacks 1..B. As in walstore at 5c29382 the jump is durable *)
|
||||
(* only as the superblock checkpoint written by the next Sync *)
|
||||
(* (walstore.go:880-935); live-lane records above it may reach disk first. *)
|
||||
(* *)
|
||||
(* Constants: *)
|
||||
(* DlLocal c1 TRUE: R stamps its own completed-Sync LSN; *)
|
||||
(* c2 FALSE (RED): R stores the primary's watermark verbatim. *)
|
||||
(* Marker g1 TRUE: the BASE install persists a gap marker covering *)
|
||||
(* 1..B; g2 FALSE (RED): no marker. *)
|
||||
(* SBWatermark Sync also persists W out of band (WALRecovery "watermarkSB").*)
|
||||
(* JumpInStamp the stamp counts the unpersisted BASE jump as synced *)
|
||||
(* (an in-memory frontier bump before the Sync that persists it).*)
|
||||
(* PromoteGate promotion only considers nodes that did not fail closed. *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS MaxLSN, B, DlLocal, Marker, SBWatermark, CorruptOn, PromoteGate, JumpInStamp
|
||||
|
||||
Nodes == {"P", "R"}
|
||||
None == [k |-> "none", lo |-> 0, hi |-> 0, dl |-> 0]
|
||||
Rec(n, d) == [k |-> "rec", lo |-> n, hi |-> n, dl |-> d]
|
||||
LSNs == 1..MaxLSN
|
||||
|
||||
VARIABLES cache, disk, synced, sbw, ckpt, next, ship, racked, acked, phase, corrupt, res, promoted
|
||||
vars == <<cache, disk, synced, sbw, ckpt, next, ship, racked, acked, phase, corrupt, res, promoted>>
|
||||
|
||||
\* P has already written and synced 1..B (acknowledged in degraded RF=1) when
|
||||
\* R is rebuilt from a durable BASE image at B; R's jump is not yet persisted
|
||||
Init ==
|
||||
/\ LET pre == [n \in LSNs |-> IF n <= B THEN Rec(n, n - 1) ELSE None]
|
||||
rwal == [n \in LSNs |-> IF B > 0 /\ Marker /\ n = B THEN [k |-> "gap", lo |-> 1, hi |-> B, dl |-> 0] ELSE None]
|
||||
IN /\ cache = [x \in Nodes |-> IF x = "P" THEN pre ELSE rwal]
|
||||
/\ disk = [x \in Nodes |-> IF x = "P" THEN pre ELSE [n \in LSNs |-> None]]
|
||||
/\ synced = [x \in Nodes |-> IF x = "P" \/ JumpInStamp THEN B ELSE 0]
|
||||
/\ sbw = [x \in Nodes |-> IF SBWatermark /\ x = "P" THEN B ELSE 0]
|
||||
/\ ckpt = [x \in Nodes |-> 0]
|
||||
/\ next = B + 1 /\ ship = <<>> /\ racked = 0 /\ acked = 0 \* acked = by P and R (1..B were RF=1 only)
|
||||
/\ phase = "run" /\ corrupt = <<"-", 0>>
|
||||
/\ res = [x \in Nodes |-> [failed |-> FALSE, frontier |-> 0]]
|
||||
/\ promoted = "-"
|
||||
|
||||
PWrite == /\ phase = "run" /\ next <= MaxLSN
|
||||
/\ cache' = [cache EXCEPT !["P"][next] = Rec(next, synced["P"])]
|
||||
/\ ship' = Append(ship, [lsn |-> next, dl |-> synced["P"]])
|
||||
/\ next' = next + 1
|
||||
/\ UNCHANGED <<disk, synced, sbw, ckpt, racked, acked, phase, corrupt, res, promoted>>
|
||||
|
||||
RRecv == /\ phase = "run" /\ ship # <<>>
|
||||
/\ LET m == Head(ship)
|
||||
IN cache' = [cache EXCEPT !["R"][m.lsn] = Rec(m.lsn, IF DlLocal THEN synced["R"] ELSE m.dl)]
|
||||
/\ ship' = Tail(ship)
|
||||
/\ UNCHANGED <<disk, synced, sbw, ckpt, next, racked, acked, phase, corrupt, res, promoted>>
|
||||
|
||||
Writeback(x) == /\ phase = "run"
|
||||
/\ \E n \in LSNs : cache[x][n] # disk[x][n] /\ disk' = [disk EXCEPT ![x][n] = cache[x][n]]
|
||||
/\ UNCHANGED <<cache, synced, sbw, ckpt, next, ship, racked, acked, phase, corrupt, res, promoted>>
|
||||
|
||||
Top(x) == LET have == {n \in LSNs : cache[x][n].k # "none"} IN IF have = {} THEN 0 ELSE CHOOSE m \in have : \A h \in have : h <= m
|
||||
|
||||
Jump(x) == IF x = "R" THEN B ELSE 0
|
||||
Sync(x) == /\ phase = "run" /\ (Top(x) > synced[x] \/ ckpt[x] < Jump(x))
|
||||
/\ LET s1 == IF Top(x) > Jump(x) THEN Top(x) ELSE Jump(x)
|
||||
IN /\ disk' = [disk EXCEPT ![x] = cache[x]]
|
||||
/\ ckpt' = [ckpt EXCEPT ![x] = IF Jump(x) > @ THEN Jump(x) ELSE @] \* WALCheckpointLSN, second fsync
|
||||
/\ synced' = [synced EXCEPT ![x] = s1]
|
||||
/\ sbw' = IF SBWatermark THEN [sbw EXCEPT ![x] = s1] ELSE sbw
|
||||
/\ racked' = IF x = "R" THEN s1 ELSE racked \* R's durable ack
|
||||
/\ UNCHANGED <<cache, next, ship, acked, phase, corrupt, res, promoted>>
|
||||
|
||||
Ack == /\ phase = "run"
|
||||
/\ LET a == IF synced["P"] < racked THEN synced["P"] ELSE racked
|
||||
IN /\ a > acked /\ acked' = a
|
||||
/\ UNCHANGED <<cache, disk, synced, sbw, ckpt, next, ship, racked, phase, corrupt, res, promoted>>
|
||||
|
||||
\* both nodes lose power; at most one durable record on one node is corrupted
|
||||
Crash == /\ phase = "run" /\ phase' = "crashed"
|
||||
/\ \/ corrupt' = <<"-", 0>>
|
||||
\/ CorruptOn /\ \E x \in Nodes, n \in LSNs : disk[x][n].k # "none" /\ corrupt' = <<x, n>>
|
||||
/\ UNCHANGED <<cache, disk, synced, sbw, ckpt, next, ship, racked, acked, res, promoted>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Max(S) == IF S = {} THEN 0 ELSE CHOOSE m \in S : \A s \in S : s <= m
|
||||
ValidSlots(x) == {n \in LSNs : disk[x][n].k # "none" /\ corrupt # <<x, n>>}
|
||||
Covered(x) == UNION {disk[x][n].lo..disk[x][n].hi : n \in ValidSlots(x)}
|
||||
RECURSIVE PrefixOf(_, _)
|
||||
PrefixOf(x, n) == IF n + 1 \in Covered(x) THEN PrefixOf(x, n + 1) ELSE n
|
||||
Wm(x) == Max({disk[x][n].dl : n \in ValidSlots(x)} \cup {sbw[x]})
|
||||
|
||||
\* watermark rule (WALRecovery "watermark"/"watermarkSB"); R's extent holds 1..B from BASE
|
||||
Recover == /\ phase = "crashed"
|
||||
/\ res' = [x \in Nodes |-> LET R == PrefixOf(x, ckpt[x])
|
||||
IN [failed |-> R < Wm(x), frontier |-> R]]
|
||||
/\ phase' = "recovered"
|
||||
/\ UNCHANGED <<cache, disk, synced, sbw, ckpt, next, ship, racked, acked, corrupt, promoted>>
|
||||
|
||||
\* promotion picks the highest recovered frontier among the candidates
|
||||
Promote == /\ phase = "recovered" /\ promoted = "-"
|
||||
/\ LET cand == IF PromoteGate THEN {x \in Nodes : ~res[x].failed} ELSE Nodes
|
||||
IN /\ cand # {}
|
||||
/\ promoted' = CHOOSE x \in cand : \A y \in cand : res[y].frontier <= res[x].frontier
|
||||
/\ phase' = "promoted"
|
||||
/\ UNCHANGED <<cache, disk, synced, sbw, ckpt, next, ship, racked, acked, corrupt, res>>
|
||||
|
||||
Next == PWrite \/ RRecv \/ Ack \/ Crash \/ Recover \/ Promote
|
||||
\/ \E x \in Nodes : Writeback(x) \/ Sync(x)
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
\* I2 per node: crash only, no corruption -> no node reports wal_corrupt
|
||||
I2 == (phase \in {"recovered", "promoted"} /\ corrupt = <<"-", 0>>) => \A x \in Nodes : ~res[x].failed
|
||||
\* I3: a node that recovered as wal_corrupt is never promoted, and every
|
||||
\* acknowledged write survives on some eligible node
|
||||
I3 == /\ phase = "promoted" => ~res[promoted].failed
|
||||
/\ phase \in {"recovered", "promoted"} => \E x \in Nodes : ~res[x].failed /\ res[x].frontier >= acked
|
||||
W_NoPromotion == ~(phase = "promoted" /\ acked >= 2)
|
||||
=============================================================================
|
||||
@@ -0,0 +1,398 @@
|
||||
-------------------------- MODULE WorkspaceTakeover --------------------------
|
||||
(***************************************************************************)
|
||||
(* S2: epoch, fencing and takeover of one sw-block workspace volume moving *)
|
||||
(* from host A (epoch 1) to host B, by a CLEAN move (detach, revoke, ACK, *)
|
||||
(* assign) or a FORCED move (lease expired, assign at a higher epoch). *)
|
||||
(* *)
|
||||
(* Plain TLA+. One action = one remote call or one local decision. A *)
|
||||
(* discrete global clock `now` is the blockmaster's (and the real) time; *)
|
||||
(* each host's clock may lag it by at most Drift ticks (bounded rate *)
|
||||
(* drift). Messages live in a set: delayed, reordered or lost. *)
|
||||
(* Code at seaweed-block main 5c293821; mapping in README.md (S2). *)
|
||||
(***************************************************************************)
|
||||
EXTENDS Integers, FiniteSets, Sequences, TLC
|
||||
|
||||
CONSTANTS
|
||||
Kinds, \* move kinds the operator may use: subset of {"clean", "forced"}
|
||||
MaxT, \* clock bound
|
||||
TTL, \* workspace lease TTL (ticks)
|
||||
ITTL, \* GC intent_ttl (ticks)
|
||||
MaxLSN, \* VM writes per host bound (as LSN)
|
||||
MaxCuts, \* cuts per host bound
|
||||
Drift, \* max ticks a host clock may fall behind the master clock
|
||||
MaxRestarts, \* blockmaster restarts
|
||||
LeaseOn, \* --workspace-lease guard on the hosts (TRUE for workspace volumes)
|
||||
\* ---- guards (TRUE = as in the code); RED variants turn one off ----
|
||||
LsnGuard, \* CASHead refuses next.remote_lsn < current chunk_remote.go:404
|
||||
StoreEpochGuard,\* CASHead refuses next.epoch < expected.epoch chunk_remote.go:391
|
||||
HostFence, \* layer fences on a HEAD of a newer epoch (supersededBy) chunk_layer.go:916,972,1032
|
||||
LayerLsnCheck, \* layer refuses a cut below HEAD.remote_lsn (lsn_behind) chunk_layer.go:800
|
||||
SeedFromObserved,\* B seeds its WAL from the HEAD its takeover CAS protects chunk_restore.go:38-43
|
||||
GCEpochRule, \* GC expires an intent only when the remote HEAD epoch > intent epoch gc.go:221
|
||||
WaitLeaseExpiry \* forced move waits for the lease to expire authority/workspace.go:314-318
|
||||
|
||||
Hosts == {"A", "B"}
|
||||
NoRec == [gen |-> 0, epoch |-> 0, holder |-> "-", st |-> "-", dgen |-> 0, lsn |-> 0, img |-> <<"-", 0>>]
|
||||
Head0 == [gen |-> 1, epoch |-> 1, holder |-> "A", st |-> "active", dgen |-> 0, lsn |-> 0, img |-> <<"A", 0>>]
|
||||
Other(h) == IF h = "A" THEN "B" ELSE "A"
|
||||
|
||||
VARIABLES
|
||||
now, lag, \* clocks
|
||||
head, stored, intents, \* remote store: HEAD, chunk bodies, intents
|
||||
msgs, \* in-flight messages
|
||||
asg, lease, ack, journal, maxEpoch, \* blockmaster durable state (authority store)
|
||||
deadline, restarts, \* blockmaster in-memory lease deadline (reset on restart)
|
||||
mv, \* operator's move in progress
|
||||
host, \* per-host state
|
||||
cut, \* per-host chunk-layer cut in progress
|
||||
bpc, bobs, \* B's attach sequence and the HEAD it observed
|
||||
hist \* history (never read by the protocol)
|
||||
|
||||
vars == <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch,
|
||||
deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
HNow(h) == now - lag[h]
|
||||
|
||||
\* the volume server admits I/O and cuts (WorkspaceLeaseGuard.permits, workspace_lease.go:57-65)
|
||||
Permits(h) == /\ host[h].epoch > 0
|
||||
/\ ~host[h].fenced
|
||||
/\ (LeaseOn => host[h].until > HNow(h))
|
||||
Serving(h) == Permits(h) /\ host[h].ready /\ ~host[h].stopIO /\ ~host[h].detached
|
||||
|
||||
\* chunk_layer.go:1032 supersededBy
|
||||
SupersededBy(h, cur) == cur.epoch > host[h].epoch \/ (cur.epoch = host[h].epoch /\ cur.holder # h /\ cur.gen # 0)
|
||||
Fences(h, cur) == HostFence /\ SupersededBy(h, cur)
|
||||
|
||||
\* CASHead (chunk_remote.go:388-425): conditional on {gen, epoch}; refuses lower epoch / lower LSN
|
||||
CasOK(base, next) == /\ head.gen = base.gen /\ head.epoch = base.epoch
|
||||
/\ (StoreEpochGuard => next.epoch >= base.epoch)
|
||||
/\ (LsnGuard => next.lsn >= head.lsn)
|
||||
|
||||
Init ==
|
||||
/\ now = 0 /\ lag = [h \in Hosts |-> 0]
|
||||
/\ head = Head0 /\ stored = {<<"A", 0>>} /\ intents = {}
|
||||
/\ msgs = {}
|
||||
/\ asg = [holder |-> "A", epoch |-> 1]
|
||||
/\ lease = [holder |-> "A", epoch |-> 1, exp |-> TTL, revoking |-> FALSE, none |-> FALSE]
|
||||
/\ ack = [gen |-> 0, holder |-> "-", epoch |-> 0]
|
||||
/\ journal = [kind |-> "-", gen |-> 0, lsn |-> 0, newEpoch |-> 0]
|
||||
/\ maxEpoch = 1
|
||||
/\ deadline = TTL /\ restarts = 0
|
||||
/\ mv = [st |-> "none", kind |-> "-", h |-> NoRec]
|
||||
/\ host = [h \in Hosts |-> IF h = "A"
|
||||
THEN [epoch |-> 1, until |-> TTL, fenced |-> FALSE, revoked |-> FALSE, stopIO |-> FALSE,
|
||||
ready |-> TRUE, detached |-> FALSE, lsn |-> 0, lh |-> Head0, renewing |-> FALSE]
|
||||
ELSE [epoch |-> 0, until |-> 0, fenced |-> FALSE, revoked |-> FALSE, stopIO |-> FALSE,
|
||||
ready |-> FALSE, detached |-> FALSE, lsn |-> 0, lh |-> NoRec, renewing |-> FALSE]]
|
||||
/\ cut = [h \in Hosts |-> [pc |-> "idle", n |-> 0, base |-> NoRec, lsn |-> 0, img |-> <<"-", 0>>, detach |-> FALSE]]
|
||||
/\ bpc = "wait" /\ bobs = NoRec
|
||||
/\ hist = [takeover |-> FALSE, aCasAfter |-> FALSE, late |-> {}, detHead |-> NoRec, bFirst |-> NoRec,
|
||||
badExpire |-> FALSE, acked |-> [h \in Hosts |-> 0], bSeed |-> -1, steps |-> <<>>,
|
||||
aStopT |-> -1, bServeT |-> -1]
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* clocks and the VM *)
|
||||
|
||||
Tick == /\ now < MaxT /\ now' = now + 1
|
||||
/\ UNCHANGED <<lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
\* the master clock advances, A's does not (bounded drift)
|
||||
SlowTick == /\ now < MaxT /\ lag["A"] < Drift
|
||||
/\ now' = now + 1 /\ lag' = [lag EXCEPT !["A"] = @ + 1]
|
||||
/\ UNCHANGED <<head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
\* a VM write accepted by a serving host (WAL LSN + 1)
|
||||
VMWrite(h) == /\ Serving(h) /\ host[h].lsn < MaxLSN
|
||||
/\ host' = [host EXCEPT ![h].lsn = @ + 1]
|
||||
/\ hist' = [hist EXCEPT !.acked[h] = host[h].lsn + 1,
|
||||
!.bServeT = IF h = "B" /\ hist.bServeT < 0 THEN now ELSE hist.bServeT]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bpc, bobs>>
|
||||
|
||||
LoseMsg == \E m \in msgs : /\ msgs' = msgs \ {m}
|
||||
/\ host' = IF m.t = "renew" \/ m.t = "lease" THEN [host EXCEPT ![m.h].renewing = FALSE] ELSE host
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bpc, bobs, hist>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* workspace lease (core/host/volume/workspace_lease.go, core/authority/workspace.go) *)
|
||||
|
||||
\* Refresh: validity anchored to the request START (workspace_lease.go:68-127)
|
||||
SendRenew(h) ==
|
||||
/\ LeaseOn /\ host[h].epoch > 0 /\ ~host[h].fenced /\ ~host[h].renewing
|
||||
/\ IF host[h].until > 0 /\ HNow(h) >= host[h].until
|
||||
THEN /\ host' = [host EXCEPT ![h].fenced = TRUE] \* expired: self-fence (:73-80)
|
||||
/\ msgs' = msgs
|
||||
ELSE /\ host' = [host EXCEPT ![h].renewing = TRUE]
|
||||
/\ msgs' = msgs \cup {[t |-> "renew", h |-> h, e |-> host[h].epoch, s |-> HNow(h)]}
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bpc, bobs, hist>>
|
||||
|
||||
\* Publisher.RenewWorkspaceLease (authority/workspace.go:73-106), reply validFor = exp - now (workspace_service.go:41-52)
|
||||
MasterRenew == \E m \in msgs :
|
||||
/\ m.t = "renew"
|
||||
/\ LET okLine == asg.holder = m.h /\ asg.epoch = m.e
|
||||
live == lease.none \/ (now < lease.exp /\ now < deadline)
|
||||
IN IF okLine /\ ~lease.none /\ lease.revoking
|
||||
THEN /\ msgs' = (msgs \ {m}) \cup {[t |-> "lease", h |-> m.h, s |-> m.s, ok |-> TRUE, valid |-> lease.exp - now, revoking |-> TRUE]}
|
||||
/\ UNCHANGED <<lease, deadline>>
|
||||
ELSE IF okLine /\ live
|
||||
THEN /\ lease' = [holder |-> m.h, epoch |-> m.e, exp |-> now + TTL, revoking |-> FALSE, none |-> FALSE]
|
||||
/\ deadline' = now + TTL
|
||||
/\ msgs' = (msgs \ {m}) \cup {[t |-> "lease", h |-> m.h, s |-> m.s, ok |-> TRUE, valid |-> TTL, revoking |-> FALSE]}
|
||||
ELSE /\ msgs' = (msgs \ {m}) \cup {[t |-> "lease", h |-> m.h, s |-> m.s, ok |-> FALSE, valid |-> 0, revoking |-> FALSE]}
|
||||
/\ UNCHANGED <<lease, deadline>>
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, ack, journal, maxEpoch, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
\* the host applies a reply (workspace_lease.go:88-127): the OLD deadline is checked first
|
||||
HostLease == \E m \in msgs :
|
||||
/\ m.t = "lease"
|
||||
/\ LET h == m.h
|
||||
t == HNow(h)
|
||||
expiredOld == host[h].until > 0 /\ t >= host[h].until
|
||||
fence == expiredOld \/ (m.ok /\ t >= m.s + m.valid) \/ m.revoking
|
||||
IN host' = [host EXCEPT ![h].renewing = FALSE,
|
||||
![h].fenced = @ \/ fence,
|
||||
![h].revoked = @ \/ m.revoking,
|
||||
![h].until = IF m.ok /\ ~fence /\ ~host[h].fenced THEN m.s + m.valid ELSE @]
|
||||
/\ msgs' = msgs \ {m}
|
||||
/\ hist' = [hist EXCEPT !.aStopT = IF m.h = "A" /\ hist.aStopT < 0 /\ m.revoking THEN now ELSE hist.aStopT]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bpc, bobs>>
|
||||
|
||||
\* drain then clean ACK with the last committed HEAD gen, only while the lease is valid (:129-160)
|
||||
SendAck ==
|
||||
/\ host["A"].revoked /\ cut["A"].pc = "idle"
|
||||
/\ host["A"].until > HNow("A") /\ host["A"].lh.gen # 0
|
||||
/\ ~\E m \in msgs : m.t = "ack"
|
||||
/\ msgs' = msgs \cup {[t |-> "ack", h |-> "A", e |-> host["A"].epoch, gen |-> host["A"].lh.gen]}
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
\* Publisher.AckWorkspaceRevocation (authority/workspace.go:215-235)
|
||||
MasterAck == \E m \in msgs :
|
||||
/\ m.t = "ack"
|
||||
/\ msgs' = msgs \ {m}
|
||||
/\ IF asg.holder = m.h /\ asg.epoch = m.e /\ m.gen # 0 /\ ~lease.none /\ lease.revoking
|
||||
/\ now < lease.exp /\ now < deadline
|
||||
THEN ack' = [gen |-> m.gen, holder |-> m.h, epoch |-> m.e]
|
||||
ELSE ack' = ack
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
\* operator: BeginWorkspaceRevocation (authority/workspace.go:200-213)
|
||||
Revoke == /\ "clean" \in Kinds /\ ~lease.none /\ ~lease.revoking /\ lease.holder = asg.holder /\ asg.holder = "A"
|
||||
/\ lease' = [lease EXCEPT !.revoking = TRUE]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
\* operator / orchestrator: stop guest I/O on A before the final cut
|
||||
StopGuest == /\ "clean" \in Kinds /\ ~host["A"].stopIO
|
||||
/\ host' = [host EXCEPT !["A"].stopIO = TRUE]
|
||||
/\ hist' = [hist EXCEPT !.aStopT = IF hist.aStopT < 0 THEN now ELSE hist.aStopT]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bpc, bobs>>
|
||||
|
||||
\* blockmaster restart: durable state kept; the in-memory deadline conservatively
|
||||
\* covers a full TTL again (authority.go:256-261)
|
||||
MasterRestart == /\ restarts < MaxRestarts
|
||||
/\ restarts' = restarts + 1
|
||||
/\ deadline' = now + TTL
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* the move (workspace_service.go:100-145, authority/workspace.go:157-198, 287-335) *)
|
||||
|
||||
\* the HEAD is read before the publisher lock (workspace_service.go:104-109)
|
||||
MoveRead == /\ mv.st = "none" /\ asg.holder = "A"
|
||||
/\ \E k \in Kinds : mv' = [st |-> "read", kind |-> k, h |-> head]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, host, cut, bpc, bobs, hist>>
|
||||
|
||||
MovePrepare ==
|
||||
/\ mv.st = "read"
|
||||
/\ LET q == mv.h
|
||||
headOK == q.gen # 0 /\ q.epoch = asg.epoch /\ q.holder = asg.holder
|
||||
cleanOK == q.st = "detached" /\ ~lease.none /\ lease.revoking /\ ack.gen = q.gen /\ ack.epoch = asg.epoch
|
||||
forcedOK == ~WaitLeaseExpiry \/ (now >= lease.exp /\ now >= deadline)
|
||||
ok == headOK /\ ~lease.none /\ IF mv.kind = "clean" THEN cleanOK ELSE forcedOK
|
||||
IN IF ok
|
||||
THEN /\ maxEpoch' = maxEpoch + 1
|
||||
/\ journal' = [kind |-> mv.kind, gen |-> q.gen, lsn |-> q.lsn, newEpoch |-> maxEpoch + 1]
|
||||
/\ asg' = [holder |-> "B", epoch |-> maxEpoch + 1]
|
||||
/\ lease' = [lease EXCEPT !.none = TRUE]
|
||||
/\ ack' = [gen |-> 0, holder |-> "-", epoch |-> 0]
|
||||
/\ msgs' = msgs \cup {[t |-> "assign", h |-> "B", e |-> maxEpoch + 1]}
|
||||
/\ mv' = [mv EXCEPT !.st = "done"]
|
||||
ELSE /\ mv' = [st |-> "none", kind |-> "-", h |-> NoRec] \* refused; may be retried
|
||||
/\ UNCHANGED <<maxEpoch, journal, asg, lease, ack, msgs>>
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, deadline, restarts, host, cut, bpc, bobs, hist>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* B: VOLUME hook -> attach -> seed -> takeover CAS -> serve
|
||||
(provider_chunk.go:229-317, chunk_restore.go:13-80) *)
|
||||
|
||||
Step(s) == hist' = [hist EXCEPT !.steps = Append(hist.steps, s)]
|
||||
|
||||
BAssign == \E m \in msgs :
|
||||
/\ m.t = "assign" /\ bpc = "wait"
|
||||
/\ msgs' = msgs \ {m}
|
||||
/\ host' = [host EXCEPT !["B"].epoch = m.e]
|
||||
/\ bpc' = "hook"
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bobs, hist>>
|
||||
|
||||
BHook == /\ bpc = "hook" /\ bpc' = "attach" /\ Step("hook") \* EnsureVolume / attach check (provider_chunk.go:240-247)
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bobs>>
|
||||
|
||||
BAttach == /\ bpc = "attach" \* ClaimChunkHead: GetHead (chunk_restore.go:30-36)
|
||||
/\ IF head.epoch > host["B"].epoch
|
||||
THEN /\ bpc' = "failed" /\ bobs' = bobs /\ hist' = hist
|
||||
ELSE /\ bpc' = "seed" /\ bobs' = head /\ Step("attach")
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut>>
|
||||
|
||||
BSeed == /\ bpc = "seed" \* PrepareRestore -> SeedChunkFrontier (provider_chunk.go:286-307)
|
||||
/\ LET L == IF SeedFromObserved THEN bobs.lsn ELSE journal.lsn
|
||||
IN /\ host' = [host EXCEPT !["B"].lsn = L]
|
||||
/\ hist' = [hist EXCEPT !.steps = Append(hist.steps, "seed"), !.bSeed = L]
|
||||
/\ bpc' = "claim"
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bobs>>
|
||||
|
||||
BClaim == /\ bpc = "claim" \* the takeover CAS (chunk_restore.go:55-79)
|
||||
/\ LET next == [bobs EXCEPT !.gen = bobs.gen + 1, !.epoch = host["B"].epoch, !.holder = "B",
|
||||
!.st = "active", !.dgen = 0]
|
||||
IN IF CasOK(bobs, next)
|
||||
THEN /\ head' = next
|
||||
/\ host' = [host EXCEPT !["B"].lh = next, !["B"].ready = TRUE]
|
||||
/\ bpc' = "claimed"
|
||||
/\ hist' = [hist EXCEPT !.steps = Append(hist.steps, "claim"), !.takeover = TRUE, !.bFirst = next]
|
||||
ELSE /\ bpc' = "attach" \* not installed: the attach is retried
|
||||
/\ UNCHANGED <<head, host, hist>>
|
||||
/\ UNCHANGED <<now, lag, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, cut, bobs>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* the chunk layer's cut on host h (chunk_layer.go:680-988) *)
|
||||
|
||||
CutStart(h, det) ==
|
||||
/\ cut[h].pc = "idle" /\ cut[h].n < MaxCuts
|
||||
/\ host[h].ready /\ Permits(h) /\ ~host[h].detached \* admit (:599-619, :695)
|
||||
/\ ~SupersededBy(h, host[h].lh) \/ ~HostFence
|
||||
/\ IF det THEN h = "A" /\ host[h].stopIO /\ "clean" \in Kinds
|
||||
ELSE host[h].lsn > host[h].lh.lsn \/ (~LayerLsnCheck /\ host[h].lsn # host[h].lh.lsn)
|
||||
/\ LayerLsnCheck => host[h].lsn >= host[h].lh.lsn \* lsn_behind (:800)
|
||||
/\ cut' = [cut EXCEPT ![h] = [pc |-> "intent", n |-> @.n, base |-> host[h].lh, lsn |-> host[h].lsn,
|
||||
img |-> <<h, @.n + 1>>, detach |-> det]]
|
||||
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, bpc, bobs, hist>>
|
||||
|
||||
CutIntent(h) == \* PutIntent before any upload (:853, :1489)
|
||||
/\ cut[h].pc = "intent"
|
||||
/\ intents' = intents \cup {[own |-> h, n |-> cut[h].n + 1, epoch |-> host[h].epoch, key |-> cut[h].img, created |-> now]}
|
||||
/\ cut' = [cut EXCEPT ![h].pc = "upload"]
|
||||
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, bpc, bobs, hist>>
|
||||
|
||||
CutUpload(h) ==
|
||||
/\ cut[h].pc = "upload"
|
||||
/\ stored' = stored \cup {cut[h].img}
|
||||
/\ hist' = [hist EXCEPT !.late = IF h = "A" /\ hist.takeover THEN @ \cup {cut[h].img} ELSE @]
|
||||
/\ cut' = [cut EXCEPT ![h].pc = "admit"]
|
||||
/\ UNCHANGED <<now, lag, head, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, bpc, bobs>>
|
||||
|
||||
DropOwn(h) == {i \in intents : ~(i.own = h /\ i.n = cut[h].n + 1)}
|
||||
|
||||
CutAdmit(h) == \* admission re-checked right before the CAS (:911-923)
|
||||
/\ cut[h].pc = "admit"
|
||||
/\ IF Permits(h) /\ (~HostFence \/ ~SupersededBy(h, host[h].lh))
|
||||
THEN /\ cut' = [cut EXCEPT ![h].pc = "cas"] /\ intents' = intents
|
||||
ELSE /\ cut' = [cut EXCEPT ![h].pc = "idle", ![h].n = @ + 1] /\ intents' = DropOwn(h)
|
||||
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, bpc, bobs, hist>>
|
||||
|
||||
CutCAS(h) == \* CASHead (:926), then settle by re-read (:957-987)
|
||||
/\ cut[h].pc = "cas"
|
||||
/\ LET b == cut[h].base
|
||||
det == cut[h].detach
|
||||
next == [gen |-> b.gen + 1, epoch |-> host[h].epoch, holder |-> h,
|
||||
st |-> IF det THEN "detached" ELSE "active", dgen |-> IF det THEN b.gen + 1 ELSE 0,
|
||||
lsn |-> cut[h].lsn, img |-> cut[h].img]
|
||||
IN IF CasOK(b, next)
|
||||
THEN /\ head' = next
|
||||
/\ host' = [host EXCEPT ![h].lh = next, ![h].detached = det]
|
||||
/\ hist' = [hist EXCEPT !.aCasAfter = @ \/ (h = "A" /\ hist.takeover),
|
||||
!.detHead = IF det THEN next ELSE @]
|
||||
ELSE /\ head' = head
|
||||
/\ host' = IF Fences(h, head) THEN [host EXCEPT ![h].fenced = TRUE, ![h].lh = head]
|
||||
ELSE [host EXCEPT ![h].lh = head]
|
||||
/\ hist' = hist
|
||||
/\ cut' = [cut EXCEPT ![h].pc = "drop"]
|
||||
/\ UNCHANGED <<now, lag, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, bpc, bobs>>
|
||||
|
||||
CutDrop(h) == \* DeleteIntent after settling (:1378-1421)
|
||||
/\ cut[h].pc = "drop"
|
||||
/\ intents' = DropOwn(h)
|
||||
/\ cut' = [cut EXCEPT ![h].pc = "idle", ![h].n = @ + 1]
|
||||
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, bpc, bobs, hist>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* GC (core/frontend/chunkstore/gc.go:108-300) *)
|
||||
|
||||
\* capture-intent expiry (gc.go:214-222): age > intent_ttl, and
|
||||
\* issued > intent epoch, HEAD epoch > intent epoch, HEAD epoch <= issued
|
||||
GCExpire == \E i \in intents :
|
||||
/\ now - i.created > ITTL
|
||||
/\ GCEpochRule => (maxEpoch > i.epoch /\ head.epoch > i.epoch /\ head.epoch <= maxEpoch)
|
||||
/\ intents' = intents \ {i}
|
||||
/\ hist' = [hist EXCEPT !.badExpire = @ \/ (i.epoch = head.epoch /\ i.own = head.holder)]
|
||||
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs>>
|
||||
|
||||
\* mark + sweep, atomic: roots are HEAD and live intents (grace abstracted, as in ChunkLifecycle)
|
||||
GCCollect == LET roots == {head.img} \cup {i.key : i \in intents}
|
||||
IN /\ stored \ roots # {}
|
||||
/\ stored' = stored \cap roots
|
||||
/\ UNCHANGED <<now, lag, head, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
Next ==
|
||||
\/ Tick \/ SlowTick \/ LoseMsg
|
||||
\/ \E h \in Hosts : VMWrite(h) \/ SendRenew(h) \/ CutStart(h, FALSE) \/ CutStart(h, TRUE)
|
||||
\/ CutIntent(h) \/ CutUpload(h) \/ CutAdmit(h) \/ CutCAS(h) \/ CutDrop(h)
|
||||
\/ MasterRenew \/ HostLease \/ SendAck \/ MasterAck \/ Revoke \/ StopGuest \/ MasterRestart
|
||||
\/ MoveRead \/ MovePrepare
|
||||
\/ BAssign \/ BHook \/ BAttach \/ BSeed \/ BClaim
|
||||
\/ GCExpire \/ GCCollect
|
||||
|
||||
Spec == Init /\ [][Next]_vars
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
(* Invariants *)
|
||||
|
||||
\* at most one host accepts VM writes at any instant (real/master time)
|
||||
NoDualServing == ~(Serving("A") /\ Serving("B"))
|
||||
|
||||
\* after B's takeover CAS no CASHead by A succeeds, and nothing A uploaded after it is reachable
|
||||
NoOldCasAfterTakeover == ~hist.aCasAfter
|
||||
NoLateChunkReachable == head.img \notin hist.late
|
||||
|
||||
\* CLEAN move loses nothing: B's first HEAD is A's detached image, and A acked nothing after it
|
||||
CleanNoLoss == (journal.kind = "clean" /\ hist.bFirst # NoRec) =>
|
||||
/\ hist.bFirst.img = hist.detHead.img /\ hist.bFirst.lsn = hist.detHead.lsn
|
||||
/\ hist.acked["A"] = hist.detHead.lsn
|
||||
|
||||
\* FORCED move: what is lost is A's journaled window (exact form, and the bound)
|
||||
ForcedLossExact == (journal.kind = "forced" /\ hist.bFirst # NoRec) =>
|
||||
hist.bFirst.lsn = journal.lsn /\ hist.bFirst.gen = journal.gen + 1
|
||||
ForcedLossBounded == (journal.kind = "forced" /\ hist.bFirst # NoRec) => hist.bFirst.lsn >= journal.lsn
|
||||
|
||||
\* GC: HEAD's chunk is stored; no intent of the current HEAD holder is expired
|
||||
GCSafe == head.img \in stored
|
||||
NoLiveIntentExpired == ~hist.badExpire
|
||||
|
||||
\* B serves only after VOLUME hook -> attach -> seed -> takeover CAS, in that order, and serves from its seed
|
||||
AttachOrder ==
|
||||
/\ Len(hist.steps) > 0 => hist.steps[1] = "hook"
|
||||
/\ \A i \in 2..Len(hist.steps) :
|
||||
/\ hist.steps[i] # "hook"
|
||||
/\ hist.steps[i] = "attach" => hist.steps[i - 1] \in {"hook", "seed"} \* a refused claim retries the attach
|
||||
/\ hist.steps[i] = "seed" => hist.steps[i - 1] = "attach"
|
||||
/\ hist.steps[i] = "claim" => hist.steps[i - 1] = "seed"
|
||||
/\ host["B"].ready => hist.takeover
|
||||
SeedMatchesTakeover == hist.bFirst # NoRec => hist.bSeed = hist.bFirst.lsn
|
||||
|
||||
\* HEAD epoch and remote_lsn never decrease
|
||||
HeadMonotone == [][head'.epoch >= head.epoch /\ head'.lsn >= head.lsn]_vars
|
||||
|
||||
\* reachability witnesses (each is EXPECTED to be violated)
|
||||
W_NoCleanServe == ~(journal.kind = "clean" /\ Serving("B") /\ hist.acked["A"] > 0)
|
||||
W_NoForcedServe == ~(journal.kind = "forced" /\ Serving("B") /\ hist.acked["A"] > 0)
|
||||
W_NoBCut == ~(head.holder = "B" /\ hist.bFirst # NoRec /\ head.gen > hist.bFirst.gen)
|
||||
W_NoRestartMove == ~(restarts > 0 /\ hist.takeover)
|
||||
|
||||
TypeOK == /\ now \in 0..MaxT /\ head.gen \in Nat /\ stored \subseteq (Hosts \X (0..MaxCuts))
|
||||
=============================================================================
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_P1_data: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_P1_data)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 4
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK AckedChunksSurvive
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_P1_giveback: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_P1_giveback)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK AckedKeptAfterGiveBack
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_P1_mark: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_P1_mark)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = FALSE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK NoProvisionalSnapMark
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_P2_aba: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_P2_aba)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1, d2, d3}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK CommitWithoutLiveClaim
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_P2_literal: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_P2_literal)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1, d2, d3}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK CommitWithoutAnyClaim
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_create: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_create)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1}
|
||||
ForkOn = FALSE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = TRUE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK NoIdReuse
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Bug_other: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_other)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 2
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = TRUE
|
||||
SweepOn = TRUE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe NoIdReuse
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Bug_other_dels: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_other_dels)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 2
|
||||
LostReply = TRUE
|
||||
PendingOn = FALSE
|
||||
SweepOn = TRUE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe NoIdReuse
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Bug_other_small: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_other_small)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = TRUE
|
||||
SweepOn = TRUE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe NoIdReuse
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_reach_W_NeverDeleted: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_reach_W_NeverDeleted)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NeverDeleted
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_reach_W_NoAckThenDelete: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_reach_W_NoAckThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoAckThenDelete
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_reach_W_NoForkThenDelete: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_reach_W_NoForkThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoForkThenDelete
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_reach_W_NoGCReclaim: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_reach_W_NoGCReclaim)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoGCReclaim
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_reach_W_NoRefusalThenDelete: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_reach_W_NoRefusalThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoRefusalThenDelete
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Bug_token: model-checks ChunkLifecycle.tla (run from docs/spec: ./run.sh Bug_token)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 2
|
||||
LostReply = TRUE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GiveBackReleases
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_P1: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_P1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1, s2}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 2
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_P2_aba: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_P2_aba)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1, d2, d3}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_create: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_create)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1}
|
||||
ForkOn = FALSE
|
||||
DelSnapOn = FALSE
|
||||
CreateOn = TRUE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_mix: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_mix)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = TRUE
|
||||
MaxHostOps = 2
|
||||
MaxRuns = 2
|
||||
LostReply = TRUE
|
||||
PendingOn = TRUE
|
||||
SweepOn = TRUE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_mix_small: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_mix_small)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = TRUE
|
||||
MaxHostOps = 2
|
||||
MaxRuns = 2
|
||||
LostReply = TRUE
|
||||
PendingOn = TRUE
|
||||
SweepOn = TRUE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NeverDeleted: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NeverDeleted)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NeverDeleted
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NoAckThenDelete: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NoAckThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoAckThenDelete
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NoForkThenDelete: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NoForkThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoForkThenDelete
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NoGCReclaim: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NoGCReclaim)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoGCReclaim
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NoHiddenNameBlock: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NoHiddenNameBlock)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = FALSE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoHiddenNameBlock
|
||||
@@ -0,0 +1,16 @@
|
||||
\* Fix_reach_W_NoRefusalThenDelete: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_reach_W_NoRefusalThenDelete)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {s1}
|
||||
Deleters = {d1, d2}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 3
|
||||
MaxRuns = 1
|
||||
LostReply = FALSE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK W_NoRefusalThenDelete
|
||||
@@ -0,0 +1,17 @@
|
||||
\* Fix_token: model-checks ChunkLifecycleFixed.tla (run from docs/spec: ./run.sh Fix_token)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
SnapCallers = {}
|
||||
Deleters = {d1}
|
||||
ForkOn = TRUE
|
||||
DelSnapOn = TRUE
|
||||
CreateOn = FALSE
|
||||
MaxHostOps = 1
|
||||
MaxRuns = 2
|
||||
LostReply = TRUE
|
||||
PendingOn = FALSE
|
||||
SweepOn = FALSE
|
||||
defaultInitValue = defaultInitValue
|
||||
SYMMETRY Symm
|
||||
INVARIANT TypeOK GCSafe SnapOnlyExplicitDelete AckedChunksSurvive CommitClean NoPublishAfterCommit NoIdReuse GiveBackReleases
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,20 @@
|
||||
\* RED_early_assign: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_early_assign)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = TRUE
|
||||
LsnGuard = TRUE
|
||||
StoreEpochGuard = TRUE
|
||||
HostFence = TRUE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = FALSE
|
||||
INVARIANT TypeOK NoDualServing
|
||||
@@ -0,0 +1,20 @@
|
||||
\* RED_epoch: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_epoch)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = FALSE
|
||||
LsnGuard = TRUE
|
||||
StoreEpochGuard = FALSE
|
||||
HostFence = FALSE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK NoOldCasAfterTakeover
|
||||
@@ -0,0 +1,20 @@
|
||||
\* RED_epoch_hostonly: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_epoch_hostonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = FALSE
|
||||
LsnGuard = TRUE
|
||||
StoreEpochGuard = TRUE
|
||||
HostFence = FALSE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK NoOldCasAfterTakeover NoLateChunkReachable
|
||||
@@ -0,0 +1,20 @@
|
||||
\* RED_epoch_storeonly: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_epoch_storeonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = FALSE
|
||||
LsnGuard = TRUE
|
||||
StoreEpochGuard = FALSE
|
||||
HostFence = TRUE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK NoOldCasAfterTakeover NoLateChunkReachable
|
||||
@@ -0,0 +1,20 @@
|
||||
\* RED_gc_ageonly: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_gc_ageonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = TRUE
|
||||
LsnGuard = TRUE
|
||||
StoreEpochGuard = TRUE
|
||||
HostFence = TRUE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = FALSE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK GCSafe
|
||||
@@ -0,0 +1,21 @@
|
||||
\* RED_lsn: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_lsn)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = TRUE
|
||||
LsnGuard = FALSE
|
||||
StoreEpochGuard = TRUE
|
||||
HostFence = TRUE
|
||||
LayerLsnCheck = FALSE
|
||||
SeedFromObserved = FALSE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK TypeOK
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,21 @@
|
||||
\* RED_lsn_storeonly: model-checks WorkspaceTakeover.tla (run from docs/spec: ./run.sh RED_lsn_storeonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
Kinds = {"forced"}
|
||||
MaxT = 4
|
||||
TTL = 2
|
||||
ITTL = 1
|
||||
MaxLSN = 2
|
||||
MaxCuts = 2
|
||||
Drift = 0
|
||||
MaxRestarts = 1
|
||||
LeaseOn = TRUE
|
||||
LsnGuard = FALSE
|
||||
StoreEpochGuard = TRUE
|
||||
HostFence = TRUE
|
||||
LayerLsnCheck = TRUE
|
||||
SeedFromObserved = TRUE
|
||||
GCEpochRule = TRUE
|
||||
WaitLeaseExpiry = TRUE
|
||||
INVARIANT TypeOK NoDualServing NoOldCasAfterTakeover NoLateChunkReachable CleanNoLoss ForcedLossBounded GCSafe NoLiveIntentExpired AttachOrder SeedMatchesTakeover
|
||||
PROPERTY HeadMonotone
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 0
|
||||
DlLocal = TRUE
|
||||
Marker = FALSE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g1_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g1_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g1_I3: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g1_I3)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = TRUE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I3
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g1_I3_inrec: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g1_I3_inrec)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = FALSE
|
||||
CorruptOn = TRUE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I3
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g1jump_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g1jump_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g2_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g2_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = FALSE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c1_g2jump_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c1_g2jump_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = FALSE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_c2_I2: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_c2_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 0
|
||||
DlLocal = FALSE
|
||||
Marker = FALSE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_nogate_I3: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_nogate_I3)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = TRUE
|
||||
PromoteGate = FALSE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT I3
|
||||
@@ -0,0 +1,12 @@
|
||||
\* S3_rep_reach: model-checks WALReplica.tla (run from docs/spec: ./run.sh S3_rep_reach)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
MaxLSN = 4
|
||||
B = 1
|
||||
DlLocal = TRUE
|
||||
Marker = TRUE
|
||||
SBWatermark = TRUE
|
||||
CorruptOn = FALSE
|
||||
PromoteGate = TRUE
|
||||
JumpInStamp = FALSE
|
||||
INVARIANT W_NoPromotion
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_current_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_current_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_current_marker_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_current_marker_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_marker_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_marker_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_marker_repair_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_marker_repair_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_marker_repair_I1Frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_marker_repair_I1Frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = FALSE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_marker_repair_I1slot: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_marker_repair_I1slot)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_marker_repair_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_marker_repair_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_ordered_repair_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_ordered_repair_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_pr155_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_pr155_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "pr155"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_pr155_marker_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_pr155_marker_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "pr155"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_pr155o_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_pr155o_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "pr155o"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_reach: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_reach)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT W_NoRecovery
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_marker_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_marker_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_marker_repair_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_marker_repair_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_marker_repair_I1Frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_marker_repair_I1Frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = FALSE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_marker_repair_I1slot: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_marker_repair_I1slot)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_marker_repair_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_marker_repair_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = TRUE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw2_watermark_repair_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw2_watermark_repair_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 5
|
||||
MaxLSN = 6
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 2
|
||||
Repair = TRUE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_current_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_current_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_current_I1frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_current_I1frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_current_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_current_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_holeFail_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_holeFail_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_holeFail_I1frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_holeFail_I1frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_holeFail_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_holeFail_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_ordered_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_ordered_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_ordered_I1frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_ordered_I1frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_ordered_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_ordered_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "ordered"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_reach: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_reach)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT W_NoRecovery
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_watermark_I1: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_watermark_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_watermark_I1frontier: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_watermark_I1frontier)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = TRUE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I1Frontier
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_sw_watermark_I2: model-checks SmartWALRecovery.tla (run from docs/spec: ./run.sh S3_sw_watermark_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
C = 3
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "watermark"
|
||||
CorruptOn = FALSE
|
||||
MaxTs = 4
|
||||
Jump = 2
|
||||
Marker = FALSE
|
||||
Rounds = 1
|
||||
Repair = FALSE
|
||||
CorruptExtent = TRUE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_current_I1: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_current_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = TRUE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_current_I1_crashonly: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_current_I1_crashonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_current_I2: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_current_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_current_prefix: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_current_prefix)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = TRUE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I0Prefix
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_current_replay: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_current_replay)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "current"
|
||||
CorruptOn = FALSE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT ReplayLastWriter
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_holeFail_I1: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_holeFail_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = TRUE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_holeFail_I2: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_holeFail_I2)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = FALSE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I2
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_holeFail_prefix: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_holeFail_prefix)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "holeFail"
|
||||
CorruptOn = TRUE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I0Prefix
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_pr155_I1: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_pr155_I1)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "pr155"
|
||||
CorruptOn = TRUE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I1
|
||||
@@ -0,0 +1,15 @@
|
||||
\* S3_wal_pr155_I1_crashonly: model-checks WALRecovery.tla (run from docs/spec: ./run.sh S3_wal_pr155_I1_crashonly)
|
||||
SPECIFICATION Spec
|
||||
CONSTANTS
|
||||
K = 4
|
||||
MaxLSN = 4
|
||||
LBAs = {"x", "y"}
|
||||
Rule = "pr155"
|
||||
CorruptOn = FALSE
|
||||
MaxCkpt = 2
|
||||
CkptLag = FALSE
|
||||
ReuseBound = "persisted"
|
||||
JumpOn = FALSE
|
||||
JumpPersistedBySync = TRUE
|
||||
Forge = FALSE
|
||||
INVARIANT I1
|
||||
Loaded 100 of 213 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user