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

txn: Unexpected transaction behavior when tidb connection got killed. #31203

Closed
longfangsong opened this issue Dec 31, 2021 · 2 comments · Fixed by tikv/client-go#417 or #33044
Closed
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@longfangsong
Copy link
Contributor

Bug Report

1. Minimal reproduce step & What did you expect to see? & What did you see instead?

# mysql client 1
begin;
update cjl.test set name='111' where id=1;
# mysql client 2
begin;
update cjl.test set name='222' where id=1;
# blocked
# mysql client 3
kill tidb <connection id of mysql client 1>;
# mysql client 1
begin;
# > ERROR 2013 (HY000): Lost connection to MySQL server during query
begin;
# > No connection. Trying to reconnect...
# > Connection id:    XXX
# > Current database: *** NONE ***
update cjl.test set name='111' where id=1;

Then either mysql client 1 or mysql client 2 should be blocked, but occationally, neither of them did.

And in that situation, if you try to commit both of them, txn in mysql client 1 will commit successfully, txn in mysql client 2 will report PessimisticLockNotFound.

2. What is your TiDB version? (Required)

Found on all 4.0 and 5.0 versions.

Note: still exists when pessimistic-txn.pipelined='false';

@longfangsong longfangsong added the type/bug The issue is confirmed as a bug. label Dec 31, 2021
@longfangsong
Copy link
Contributor Author

/assign

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Jan 4, 2022

If the pessimistic lock wait takes some long time greater than the ManagedLockTTL which is 20s, the ttlManager may not update the new ttl in time as it will update every ManagedLockTTL/2 time every round. The conflict transaction could resolve the lock before the first time ttl time update.

To reduce this possibility, the ttl field could be updated locking keys.

@jebter jebter added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. labels Jan 11, 2022
longfangsong added a commit to longfangsong/tidb that referenced this issue Mar 14, 2022
ref pingcap#31203

Signed-off-by: longfangsong <longfangsong@icloud.com>
@longfangsong longfangsong mentioned this issue Mar 14, 2022
12 tasks
ti-chi-bot pushed a commit that referenced this issue Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
4 participants