Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction specs may be not as solid as expected #28

Open
sticnarf opened this issue Oct 21, 2019 · 2 comments
Open

Transaction specs may be not as solid as expected #28

sticnarf opened this issue Oct 21, 2019 · 2 comments

Comments

@sticnarf
Copy link
Contributor

I try to reproduce the bug which is fixed by tikv/tikv#5673. The bug is introduced by the new check_txn_status API, which is a cleanup API substitution. We forgot to write rollback when there is no lock.

To reproduce the problem in TLA+, I change the eraseLock in CollapseRollbacks by:

eraseLock(key, l) == 
        IF l \in key_lock[key]
        THEN
            /\ key_data' = [key_data EXCEPT ![key] = @ \ {[ts |-> l.ts]}]
            /\ key_lock' = [key_lock EXCEPT ![key] = @ \ {l}]
            /\ key_write' = [key_write EXCEPT ![key] =
                         Append(@, [ts |-> l.ts, type |-> "rollback"])]
        ELSE
            UNCHANGED <<key_data, key_lock, key_write>>

This demonstrates the wrong implementation in tikv/tikv#5390. However, the tests still pass.

@sticnarf
Copy link
Contributor Author

sticnarf commented Oct 28, 2019

#29 can successfully reproduce this problem.

Changing rollback(k, ts) to:

rollback(k, ts) ==
  IF key_lock[k] # {}
  THEN
      \* If the existing lock has the same ts, unlock it.
      /\ IF \E l \in key_lock[k] : l.ts = ts
         THEN key_lock' = [key_lock EXCEPT ![k] = {}]
         ELSE UNCHANGED key_lock
      /\ key_data' = [key_data EXCEPT ![k] = @ \ {[ts |-> ts]}]
      \* Write a rollback in the write column.
      /\ key_write' = [key_write EXCEPT
           ![k] = (@ \ {w \in latestHistoryWrite(k, ts) : w.type = "rollback"}) \* collapse rollback
                     \union {[ts |-> ts, type |-> "rollback", start_ts |-> ts]}]
  ELSE
    UNCHANGED <<key_lock, key_data, key_write>>

It's quite easy to get Invariant CommittedTxnConsistency is violated.

@IANTHEREAL
Copy link
Contributor

IANTHEREAL commented Nov 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants