mirror of
https://github.com/pingcap/tla-plus.git
synced 2024-12-26 20:40:15 +08:00
implement collapse rollback
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
This commit is contained in:
parent
be9ddc9e7a
commit
c9af93cee7
@ -71,6 +71,15 @@ Range(m) == {m[i] : i \in DOMAIN m}
|
|||||||
findStaleLock(k, ts) ==
|
findStaleLock(k, ts) ==
|
||||||
{l \in key_lock[k] : l.pessimistic = FALSE /\ l.ts < ts}
|
{l \in key_lock[k] : l.pessimistic = FALSE /\ l.ts < ts}
|
||||||
|
|
||||||
|
\* Get the write records of k before or at timestamp ts
|
||||||
|
historyWrites(k, ts) ==
|
||||||
|
{w \in key_write[k] : w.ts <= ts}
|
||||||
|
|
||||||
|
\* Get the set of the latest write record of k before or at timestamp ts
|
||||||
|
latestHistoryWrite(k, ts) ==
|
||||||
|
{w \in historyWrites(k, ts) :
|
||||||
|
\A w2 \in historyWrites(k, ts) : w.ts >= w2.ts}
|
||||||
|
|
||||||
\* Rollback key k in the transaction starting at ts
|
\* Rollback key k in the transaction starting at ts
|
||||||
rollback(k, ts) ==
|
rollback(k, ts) ==
|
||||||
\* If the existing lock has the same ts, unlock it.
|
\* If the existing lock has the same ts, unlock it.
|
||||||
@ -79,9 +88,10 @@ rollback(k, ts) ==
|
|||||||
ELSE UNCHANGED key_lock
|
ELSE UNCHANGED key_lock
|
||||||
/\ key_data' = [key_data EXCEPT ![k] = @ \ {[ts |-> ts]}]
|
/\ key_data' = [key_data EXCEPT ![k] = @ \ {[ts |-> ts]}]
|
||||||
\* Write a rollback in the write column.
|
\* Write a rollback in the write column.
|
||||||
\* TODO: collapse rollback
|
|
||||||
/\ key_write' = [key_write EXCEPT
|
/\ key_write' = [key_write EXCEPT
|
||||||
![k] = @ \union {[ts |-> ts, type |-> "rollback", start_ts |-> ts]}]
|
![k] = (@ \ {w \in latestHistoryWrite(k, ts) : w.type = "rollback"}) \* collapse rollback
|
||||||
|
\union {[ts |-> ts, type |-> "rollback", start_ts |-> ts]}]
|
||||||
|
|
||||||
|
|
||||||
\* Commit key k
|
\* Commit key k
|
||||||
commit(k, start_ts, commit_ts) ==
|
commit(k, start_ts, commit_ts) ==
|
||||||
@ -377,19 +387,10 @@ ServerOp ==
|
|||||||
\/ DoCommit
|
\/ DoCommit
|
||||||
|
|
||||||
Read ==
|
Read ==
|
||||||
\* Read by a running transaction
|
\E ts \in 0..next_ts :
|
||||||
\/ \E c \in CLIENT :
|
\E k \in KEY :
|
||||||
/\ client_state[c] = "working"
|
/\ msg' = msg \union {[type |-> "read", key |-> k, ts |-> next_ts]}
|
||||||
/\ \E k \in KEY :
|
/\ UNCHANGED <<next_ts, client_vars, key_vars>>
|
||||||
msg' = msg \union
|
|
||||||
{[type |-> "read", key |-> k, ts |-> client_ts[c].start_ts]}
|
|
||||||
/\ UNCHANGED <<next_ts, client_vars, key_vars>>
|
|
||||||
\* When all transactions are finished, we read all keys with latest TS
|
|
||||||
\/ /\ \A c \in CLIENT : client_state[c] \in {"committed", "aborted", "undetermined"}
|
|
||||||
/\ \E k \in KEY :
|
|
||||||
msg' = msg \union
|
|
||||||
{[type |-> "read", key |-> k, ts |-> next_ts]}
|
|
||||||
/\ UNCHANGED <<next_ts, client_vars, key_vars>>
|
|
||||||
|
|
||||||
Init ==
|
Init ==
|
||||||
/\ next_ts = 1
|
/\ next_ts = 1
|
||||||
@ -454,8 +455,7 @@ MsgTypeInv ==
|
|||||||
[c : CLIENT, type : {"commit"}, key : KEY, start_ts : Pos, commit_ts : Pos] \union
|
[c : CLIENT, type : {"commit"}, key : KEY, start_ts : Pos, commit_ts : Pos] \union
|
||||||
[type : {"read"}, key : KEY, ts : Nat] \union
|
[type : {"read"}, key : KEY, ts : Nat] \union
|
||||||
[type : {"cleanup"}, primary : KEY, start_ts : Pos] \union
|
[type : {"cleanup"}, primary : KEY, start_ts : Pos] \union
|
||||||
[type : {"resolve"}, primary : KEY, start_ts : Pos, commit_ts : Nat] \union
|
[type : {"resolve"}, primary : KEY, start_ts : Pos, commit_ts : Nat]
|
||||||
[type : {"rollback"}, key : SUBSET KEY, start_ts: Pos]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
TypeInvariant ==
|
TypeInvariant ==
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<launchConfiguration type="org.lamport.tla.toolbox.tool.tlc.modelCheck">
|
<launchConfiguration type="org.lamport.tla.toolbox.tool.tlc.modelCheck">
|
||||||
<stringAttribute key="TLCCmdLineParameters" value=""/>
|
<stringAttribute key="TLCCmdLineParameters" value=""/>
|
||||||
<intAttribute key="collectCoverage" value="1"/>
|
<intAttribute key="collectCoverage" value="0"/>
|
||||||
<stringAttribute key="configurationName" value="Test1"/>
|
<stringAttribute key="configurationName" value="Test1"/>
|
||||||
<booleanAttribute key="deferLiveness" value="false"/>
|
<booleanAttribute key="deferLiveness" value="false"/>
|
||||||
<intAttribute key="dfidDepth" value="100"/>
|
<intAttribute key="dfidDepth" value="100"/>
|
||||||
@ -12,9 +12,9 @@
|
|||||||
<stringAttribute key="distributedTLC" value="off"/>
|
<stringAttribute key="distributedTLC" value="off"/>
|
||||||
<stringAttribute key="distributedTLCVMArgs" value=""/>
|
<stringAttribute key="distributedTLCVMArgs" value=""/>
|
||||||
<intAttribute key="fpBits" value="1"/>
|
<intAttribute key="fpBits" value="1"/>
|
||||||
<intAttribute key="fpIndex" value="122"/>
|
<intAttribute key="fpIndex" value="84"/>
|
||||||
<booleanAttribute key="fpIndexRandom" value="true"/>
|
<booleanAttribute key="fpIndexRandom" value="true"/>
|
||||||
<intAttribute key="maxHeapSize" value="73"/>
|
<intAttribute key="maxHeapSize" value="75"/>
|
||||||
<intAttribute key="maxSetSize" value="1000000"/>
|
<intAttribute key="maxSetSize" value="1000000"/>
|
||||||
<booleanAttribute key="mcMode" value="true"/>
|
<booleanAttribute key="mcMode" value="true"/>
|
||||||
<stringAttribute key="modelBehaviorInit" value="Init"/>
|
<stringAttribute key="modelBehaviorInit" value="Init"/>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<stringAttribute key="modelExpressionEval" value=""/>
|
<stringAttribute key="modelExpressionEval" value=""/>
|
||||||
<listAttribute key="modelParameterConstants">
|
<listAttribute key="modelParameterConstants">
|
||||||
<listEntry value="KEY;;{k1, k2};1;1"/>
|
<listEntry value="KEY;;{k1, k2};1;1"/>
|
||||||
<listEntry value="CLIENT;;{c1};1;1"/>
|
<listEntry value="CLIENT;;{c1, c2};1;1"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<intAttribute key="numberOfWorkers" value="12"/>
|
<intAttribute key="numberOfWorkers" value="12"/>
|
||||||
<booleanAttribute key="recover" value="false"/>
|
<booleanAttribute key="recover" value="false"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user