|
|
|
@@ -9,6 +9,17 @@
|
|
|
|
|
(* 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). *)
|
|
|
|
|
(* *)
|
|
|
|
|
(* #205, durable lease horizon (PR #209): lease.exp is the PUBLISHED *)
|
|
|
|
|
(* horizon (the blockmaster's in-memory copy of the durable record), dhz *)
|
|
|
|
|
(* the horizon on DISK, deadline the latest grant (memory only). A renewal *)
|
|
|
|
|
(* of a live lease writes nothing: grant = min(now + TTL, lease.exp). An *)
|
|
|
|
|
(* extension is an ordinary serialized writer that raises the horizon to *)
|
|
|
|
|
(* trigger + TTL + HSlack; its write may fail without landing or fail *)
|
|
|
|
|
(* after landing (unknown outcome). Any failed write latches `uncertain`: *)
|
|
|
|
|
(* renewals and other writes are refused until a restart reloads the disk. *)
|
|
|
|
|
(* Nondecreasing `now` (Tick/SlowTick only advance it) is an ASSUMPTION of *)
|
|
|
|
|
(* this model, not a property of the deployment's clocks. *)
|
|
|
|
|
(***************************************************************************)
|
|
|
|
|
EXTENDS Integers, FiniteSets, Sequences, TLC
|
|
|
|
|
|
|
|
|
@@ -29,19 +40,28 @@ CONSTANTS
|
|
|
|
|
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
|
|
|
|
|
WaitLeaseExpiry,\* forced move waits for the lease to expire authority/workspace.go:314-318
|
|
|
|
|
Clamp, \* #205: a renewal's grant is clamped to the published horizon (FALSE: unsafe memory-only renewal)
|
|
|
|
|
ExtFail \* #205: an extension write may fail, landed or not (unknown outcome -> uncertain)
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
Min(a, b) == IF a < b THEN a ELSE b
|
|
|
|
|
Max(a, b) == IF a > b THEN a ELSE b
|
|
|
|
|
\* #205 horizon geometry (workspace_lease_view.go): an extension writes H = trigger + TTL + HSlack; a renewal
|
|
|
|
|
\* triggers one when the published horizon is closer than TTL + Margin. Code: TTL/2 and TTL/4; at least one tick here.
|
|
|
|
|
HSlack == Max(1, TTL \div 2)
|
|
|
|
|
Margin == Max(1, TTL \div 4)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
asg, lease, ack, journal, maxEpoch, \* blockmaster published state (= the authority store unless uncertain)
|
|
|
|
|
deadline, restarts, \* blockmaster in-memory lease deadline (the latest grant; reset on restart)
|
|
|
|
|
dhz, uncertain, extReq, \* #205: horizon on disk; a write outcome is unknown; pending extension trigger time (-1: none)
|
|
|
|
|
mv, \* operator's move in progress
|
|
|
|
|
host, \* per-host state
|
|
|
|
|
cut, \* per-host chunk-layer cut in progress
|
|
|
|
@@ -49,7 +69,7 @@ VARIABLES
|
|
|
|
|
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>>
|
|
|
|
|
deadline, restarts, dhz, uncertain, extReq, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
HNow(h) == now - lag[h]
|
|
|
|
|
|
|
|
|
@@ -73,11 +93,13 @@ Init ==
|
|
|
|
|
/\ head = Head0 /\ stored = {<<"A", 0>>} /\ intents = {}
|
|
|
|
|
/\ msgs = {}
|
|
|
|
|
/\ asg = [holder |-> "A", epoch |-> 1]
|
|
|
|
|
/\ lease = [holder |-> "A", epoch |-> 1, exp |-> TTL, revoking |-> FALSE, none |-> FALSE]
|
|
|
|
|
\* A's first grant: horizon now + TTL + HSlack on disk, grant (deadline, A's validity) now + TTL
|
|
|
|
|
/\ lease = [holder |-> "A", epoch |-> 1, exp |-> TTL + HSlack, revoking |-> FALSE, none |-> FALSE]
|
|
|
|
|
/\ ack = [gen |-> 0, holder |-> "-", epoch |-> 0]
|
|
|
|
|
/\ journal = [kind |-> "-", gen |-> 0, lsn |-> 0, newEpoch |-> 0]
|
|
|
|
|
/\ maxEpoch = 1
|
|
|
|
|
/\ deadline = TTL /\ restarts = 0
|
|
|
|
|
/\ dhz = TTL + HSlack /\ uncertain = FALSE /\ extReq = -1
|
|
|
|
|
/\ mv = [st |-> "none", kind |-> "-", h |-> NoRec]
|
|
|
|
|
/\ host = [h \in Hosts |-> IF h = "A"
|
|
|
|
|
THEN [epoch |-> 1, until |-> TTL, fenced |-> FALSE, revoked |-> FALSE, stopIO |-> FALSE,
|
|
|
|
@@ -94,25 +116,25 @@ Init ==
|
|
|
|
|
(* 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>>
|
|
|
|
|
/\ UNCHANGED <<lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
(* workspace lease (core/host/volume/workspace_lease.go, core/authority/workspace.go) *)
|
|
|
|
|
(* workspace lease (core/host/volume/workspace_lease.go, core/authority/workspace_lease_view.go) *)
|
|
|
|
|
|
|
|
|
|
\* Refresh: validity anchored to the request START (workspace_lease.go:68-127)
|
|
|
|
|
SendRenew(h) ==
|
|
|
|
@@ -122,23 +144,51 @@ SendRenew(h) ==
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
\* Publisher.RenewWorkspaceLease (authority/workspace.go:73-106), reply validFor = exp - now (workspace_service.go:41-52)
|
|
|
|
|
\* Publisher.RenewWorkspaceLease (#205, workspace_lease_view.go), reply validFor = expiry - now (workspace_service.go leaseFact).
|
|
|
|
|
\* - Revoking: the drain reply, expiry min(horizon, deadline); never extends (allowed while uncertain, as before).
|
|
|
|
|
\* - No lease yet: the FIRST grant, a synchronous durable write (refused while uncertain): horizon now + TTL + HSlack.
|
|
|
|
|
\* - Live lease: memory only. grant = min(now + TTL, horizon) (Clamp); refused while uncertain or when it leaves no
|
|
|
|
|
\* validity; deadline = max(deadline, grant); triggers an extension when the horizon is closer than TTL + Margin.
|
|
|
|
|
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)
|
|
|
|
|
Reply(ok, v, rv) == [t |-> "lease", h |-> m.h, s |-> m.s, ok |-> ok, valid |-> v, revoking |-> rv]
|
|
|
|
|
grant == IF Clamp THEN Min(now + TTL, lease.exp) ELSE now + TTL
|
|
|
|
|
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]
|
|
|
|
|
THEN /\ msgs' = (msgs \ {m}) \cup {Reply(TRUE, Min(lease.exp, deadline) - now, TRUE)}
|
|
|
|
|
/\ UNCHANGED <<lease, deadline, dhz, extReq>>
|
|
|
|
|
ELSE IF okLine /\ lease.none /\ ~uncertain
|
|
|
|
|
THEN /\ lease' = [holder |-> m.h, epoch |-> m.e, exp |-> now + TTL + HSlack, revoking |-> FALSE, none |-> FALSE]
|
|
|
|
|
/\ dhz' = now + TTL + HSlack
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ msgs' = (msgs \ {m}) \cup {Reply(TRUE, TTL, FALSE)}
|
|
|
|
|
/\ extReq' = extReq
|
|
|
|
|
ELSE IF okLine /\ ~lease.none /\ now < lease.exp /\ now < deadline /\ ~uncertain /\ grant > now
|
|
|
|
|
THEN /\ deadline' = Max(deadline, grant)
|
|
|
|
|
/\ extReq' = IF lease.exp < now + TTL + Margin /\ extReq < 0 THEN now ELSE extReq
|
|
|
|
|
/\ msgs' = (msgs \ {m}) \cup {Reply(TRUE, grant - now, FALSE)}
|
|
|
|
|
/\ UNCHANGED <<lease, dhz>>
|
|
|
|
|
ELSE /\ msgs' = (msgs \ {m}) \cup {Reply(FALSE, 0, FALSE)}
|
|
|
|
|
/\ UNCHANGED <<lease, deadline, dhz, extReq>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, ack, journal, maxEpoch, restarts, uncertain, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
\* the extender (#205, workspace_lease_view.go extendWorkspaceLease): an ordinary writer serialized with every other
|
|
|
|
|
\* write; it rechecks the lease and writes H = trigger + TTL + HSlack. Success publishes H. A failed write latches
|
|
|
|
|
\* uncertain whether or not it landed on disk (ExtFail). A failed recheck is a known no-write.
|
|
|
|
|
MasterExtend ==
|
|
|
|
|
/\ extReq >= 0
|
|
|
|
|
/\ LET H == extReq + TTL + HSlack
|
|
|
|
|
ok == /\ ~lease.none /\ ~lease.revoking /\ ~uncertain
|
|
|
|
|
/\ lease.holder = asg.holder /\ lease.epoch = asg.epoch /\ H > lease.exp
|
|
|
|
|
IN IF ok
|
|
|
|
|
THEN \/ /\ lease' = [lease EXCEPT !.exp = H] /\ dhz' = H /\ uncertain' = uncertain
|
|
|
|
|
\/ /\ ExtFail /\ lease' = lease /\ dhz' = dhz /\ uncertain' = TRUE \* failed, nothing landed
|
|
|
|
|
\/ /\ ExtFail /\ lease' = lease /\ dhz' = H /\ uncertain' = TRUE \* landed, reply lost
|
|
|
|
|
ELSE UNCHANGED <<lease, dhz, uncertain>>
|
|
|
|
|
/\ extReq' = -1
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, ack, journal, maxEpoch, deadline, 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 :
|
|
|
|
@@ -153,7 +203,7 @@ HostLease == \E m \in msgs :
|
|
|
|
|
![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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, cut, bpc, bobs>>
|
|
|
|
|
|
|
|
|
|
\* drain then clean ACK with the last committed HEAD gen, only while the lease is valid (:129-160)
|
|
|
|
|
SendAck ==
|
|
|
|
@@ -161,35 +211,39 @@ SendAck ==
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
\* Publisher.AckWorkspaceRevocation (authority/workspace.go:215-235)
|
|
|
|
|
\* Publisher.AckWorkspaceRevocation (authority/workspace.go:215-235): a durable write (refused while uncertain)
|
|
|
|
|
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
|
|
|
|
|
/\ now < lease.exp /\ now < deadline /\ ~uncertain
|
|
|
|
|
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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
\* operator: BeginWorkspaceRevocation (authority/workspace.go:200-213)
|
|
|
|
|
\* operator: BeginWorkspaceRevocation (authority/workspace.go:200-213): a durable write (refused while uncertain)
|
|
|
|
|
Revoke == /\ "clean" \in Kinds /\ ~lease.none /\ ~lease.revoking /\ lease.holder = asg.holder /\ asg.holder = "A"
|
|
|
|
|
/\ ~uncertain
|
|
|
|
|
/\ lease' = [lease EXCEPT !.revoking = TRUE]
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, ack, journal, maxEpoch, deadline, restarts, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, cut, bpc, bobs>>
|
|
|
|
|
|
|
|
|
|
\* blockmaster restart: durable state kept; the in-memory deadline conservatively
|
|
|
|
|
\* covers a full TTL again (authority.go:256-261)
|
|
|
|
|
\* blockmaster restart: the published state is reloaded from disk (so the published horizon becomes dhz), the
|
|
|
|
|
\* in-memory deadline conservatively covers a full TTL again (authority.go reloadFromStore), uncertainty and any
|
|
|
|
|
\* pending extension are gone
|
|
|
|
|
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>>
|
|
|
|
|
/\ lease' = IF lease.none THEN lease ELSE [lease EXCEPT !.exp = dhz]
|
|
|
|
|
/\ uncertain' = FALSE /\ extReq' = -1
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, ack, journal, maxEpoch, dhz, mv, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
(* the move (workspace_service.go:100-145, authority/workspace.go:157-198, 287-335) *)
|
|
|
|
@@ -197,15 +251,17 @@ MasterRestart == /\ restarts < MaxRestarts
|
|
|
|
|
\* 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
\* a durable write (refused while uncertain, authority.go apply); the forced barrier reads the published horizon
|
|
|
|
|
\* and the in-memory deadline
|
|
|
|
|
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
|
|
|
|
|
ok == headOK /\ ~lease.none /\ ~uncertain /\ 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]
|
|
|
|
@@ -216,7 +272,7 @@ MovePrepare ==
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, deadline, restarts, dhz, uncertain, extReq, host, cut, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
(* B: VOLUME hook -> attach -> seed -> takeover CAS -> serve
|
|
|
|
@@ -229,23 +285,23 @@ BAssign == \E m \in msgs :
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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",
|
|
|
|
@@ -257,7 +313,7 @@ BClaim == /\ bpc = "claim" \* the takeover
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, cut, bobs>>
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
(* the chunk layer's cut on host h (chunk_layer.go:680-988) *)
|
|
|
|
@@ -271,20 +327,20 @@ CutStart(h, det) ==
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, host, bpc, bobs>>
|
|
|
|
|
|
|
|
|
|
DropOwn(h) == {i \in intents : ~(i.own = h /\ i.n = cut[h].n + 1)}
|
|
|
|
|
|
|
|
|
@@ -293,7 +349,7 @@ CutAdmit(h) == \* admis
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, host, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
CutCAS(h) == \* CASHead (:926), then settle by re-read (:957-987)
|
|
|
|
|
/\ cut[h].pc = "cas"
|
|
|
|
@@ -312,13 +368,13 @@ CutCAS(h) == \* CASHe
|
|
|
|
|
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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, stored, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, mv, host, bpc, bobs, hist>>
|
|
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
(* GC (core/frontend/chunkstore/gc.go:108-300) *)
|
|
|
|
@@ -330,20 +386,20 @@ GCExpire == \E i \in intents :
|
|
|
|
|
/\ 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, stored, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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>>
|
|
|
|
|
/\ UNCHANGED <<now, lag, head, intents, msgs, asg, lease, ack, journal, maxEpoch, deadline, restarts, dhz, uncertain, extReq, 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
|
|
|
|
|
\/ MasterRenew \/ MasterExtend \/ HostLease \/ SendAck \/ MasterAck \/ Revoke \/ StopGuest \/ MasterRestart
|
|
|
|
|
\/ MoveRead \/ MovePrepare
|
|
|
|
|
\/ BAssign \/ BHook \/ BAttach \/ BSeed \/ BClaim
|
|
|
|
|
\/ GCExpire \/ GCCollect
|
|
|
|
@@ -388,11 +444,21 @@ 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
|
|
|
|
|
|
|
|
|
|
\* #205 (S1, scoped to the active lease): the current holder's validity never exceeds the published horizon, and the
|
|
|
|
|
\* published horizon never exceeds the disk; they are equal unless a write outcome is unknown
|
|
|
|
|
HostWithinHorizon == ~lease.none =>
|
|
|
|
|
\A h \in Hosts : (h = lease.holder /\ host[h].epoch = lease.epoch) => host[h].until <= lease.exp
|
|
|
|
|
DiskCoversMemory == ~lease.none => (lease.exp <= dhz /\ (~uncertain => lease.exp = dhz))
|
|
|
|
|
|
|
|
|
|
\* 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)
|
|
|
|
|
W_NoExtension == ~(~lease.none /\ lease.epoch = 1 /\ lease.exp > TTL + HSlack) \* an extension raised A's horizon
|
|
|
|
|
W_NoExtLanded == ~(~lease.none /\ dhz > lease.exp) \* a failed extension landed on disk
|
|
|
|
|
W_NoUncertain == ~uncertain
|
|
|
|
|
|
|
|
|
|
TypeOK == /\ now \in 0..MaxT /\ head.gen \in Nat /\ stored \subseteq (Hosts \X (0..MaxCuts))
|
|
|
|
|
/\ uncertain \in BOOLEAN /\ extReq \in -1..MaxT
|
|
|
|
|
=============================================================================
|