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

TxnHeartbeat may start too late if locking the first keys takes too long #26801

Closed
sticnarf opened this issue Aug 2, 2021 · 3 comments
Closed
Labels
severity/moderate sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@sticnarf
Copy link
Contributor

sticnarf commented Aug 2, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Begin a pessimistic transaction T1.
  2. In the first write SQL, write a lot of keys such as delete * from t from a big table. To reproduce the issue, this step should take longer than 20 seconds.
  3. Mutate the keys that is already locked in step 2 from another transaction T2.
  4. Commit the transaction T1.

2. What did you expect to see? (Required)

Step 3 should block. T1 should commit successfully in step 4.

3. What did you see instead (Required)

Step 3 succeeds. Step 4 reports PessimisticLockNotFound.

4. What is your TiDB version? (Required)

TiDB 3.0+

@sticnarf sticnarf added type/bug The issue is confirmed as a bug. sig/transaction SIG:Transaction severity/moderate labels Aug 2, 2021
@sticnarf
Copy link
Contributor Author

sticnarf commented Aug 2, 2021

The keep alive goroutine is launched after the keys are all locked.

Locking the keys may involve multiple requests and the primary key is locked first. So, after all the keys are locked, the primary lock may have been expired.

When another transaction encounters the expired locks, they can clear the locks. So before the keep alive goroutine starts, some pessimistic locks have already been removed. Therefore, the transaction will finally fail to commit.

@youjiali1995
Copy link
Contributor

Fixed by tikv/client-go#261.

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'backport-x.y.z',
and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants