-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: fix bug that the kill command doesn't work when the killed session is waiting for the pessimistic lock #12852
Conversation
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #12852 +/- ##
================================================
- Coverage 80.0759% 80.0376% -0.0384%
================================================
Files 465 465
Lines 107649 106721 -928
================================================
- Hits 86201 85417 -784
+ Misses 14967 14908 -59
+ Partials 6481 6396 -85 |
tk.MustExec("insert test_kill values (1, 1)") | ||
tk.MustExec("begin pessimistic") | ||
tk2.MustExec("begin pessimistic") | ||
tk.MustQuery("select * from test_kill where id = 1 for update") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a test case for MAX_EXECUTION_TIME
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I test it manually and currently MAX_EXECUTION_TIME
works when the session is waiting for a lock.
Does MySQL have different behavior? @jackysp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL has the same behavior.
store/tikv/2pc.go
Outdated
if err1 := bo.BackoffWithMaxSleep(boTxnLockFast, int(expire), errors.New(locks[0].String())); err1 != nil { | ||
return err1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to add this backoff here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm.... maybe I know: do you just want to check bo.ctx.Done()
?
first batch is canceled by action.kill, then other batchs will use bo.ctx.Done()
, batchExecutor
will return until all batch be cancelled.. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... it seems doesn't work @tiancaiamao
Line 1222 in 2ec341e
if _, ok := batchExe.action.(actionPrewrite); ok { |
this line, we just can cancel actionPrewrite
, actionPessimisticLock
also need cancel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can call time.Sleep
or bo.Backoff
, I choose backoff because it may generate better error. @lysu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coprocessor also use backoff like this https://github.com/pingcap/tidb/blob/master/store/tikv/coprocessor.go#L792
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally, we think about TxnLockFast
as read-conflict in metric
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to BoTxnLock @lysu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
efddcf6#diff-4ef55fe1237c7e6bb2217ccca37b9f5fR439 @tiancaiamao do we need to make |
LGTM |
1c1f6ee
to
d0525b3
Compare
The problem out of the scope of this PR means to solve. @lysu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/rebuild
|
cherry pick to release-3.0 failed |
cherry pick to release-3.1 failed |
…ect/tidb into feature-add-udf-support * 'feature-add-udf-support' of https://github.com/JustProject/tidb: (26 commits) *: fix bug that the kill command doesn't work when the killed session is waiting for the pessimistic lock (pingcap#12852) executor: fix the projection upon the indexLookUp in indexLookUpJoin can't get result. (pingcap#12889) planner, executor: support create view on union (pingcap#12595) planner/cascades: introduce TransformationID in cascades planner (pingcap#12879) executor: fix data race in test (pingcap#12910) executor: reuse chunk row for insert on duplicate update (pingcap#12847) ddl: speed up tests (pingcap#12888) executor: speed up test (pingcap#12896) expression: implement vectorized evaluation for `builtinSecondSig` (pingcap#12886) expression: implement vectorized evaluation for `builtinJSONObjectSig` (pingcap#12663) expression: speed up builtinRepeatSig by using MergeNulls (pingcap#12674) expression: speed up unit tests under the expression package (pingcap#12887) store,kv: snapshot doesn't cache the non-exists kv entries lead to poor 'insert ignore' performance (pingcap#12872) executor: fix data race in `GetDirtyTable()` (pingcap#12767) domain: increase TTL to reduce the occurrence of reporting min startTS errors (pingcap#12578) executor: split test for speed up (pingcap#12881) executor: fix inconsistent of grants privileges with MySQL when executing `grant all on ...` (pingcap#12330) expression: implement vectorized evaluation for `builtinJSONUnquoteSig` (pingcap#12841) tune grpc connection count between tidb and tikv (pingcap#12884) Makefile: change test parallel to 8 (pingcap#12885) ...
@tiancaiamao need cherry pick to 3.1? |
… is waiting for the pessimistic lock (pingcap#12852)
What problem does this PR solve?
What is changed and how it works?
Fix bug that the kill command doesn't work when the killed session is waiting for the pessimistic lock.
The
killed
flag is checked when the code runs toexecutor.Next()
, but when the transaction is acquiring the pessimistic lock, it blocks and never runs toexecutor.Next()
, so the kill command can't work.Check List
Tests
Code changes
Related changes
Release note