-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: support select for update no wait #12775
Conversation
store/tikv/2pc.go
Outdated
// Check lock conflict error for nowait, if nowait set and key locked by others | ||
// report error immediately and do no resolve locks any more | ||
if c.lockNoWait { | ||
if keyErr.GetLocked() != nil { |
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.
can this lock be a committed
or rollbacked
lock in pessimistic txn and need check lock state? I'm not familiar with this :D
// the async rollback operation rollbacked the lock just acquired | ||
newForUpdateTS, tsErr := a.Ctx.GetStore().GetOracle().GetTimestamp(ctx) | ||
if tsErr != nil { | ||
return nil, tsErr |
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.
if fail happened here, UpdateTS
will not be updated, and the previous async rollback is possiblely ongoing,
still risk that the later select for update
rollbacked ? @coocood
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.
This error rarely happens, so even if this happened, the async rollback causes the transaction to fail, it is acceptable.
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.
@tiancaiamao @coocood @jackysp
I'll add and use getWithRetry
, but I think here still risk with nowait
. User get this statement result error, next statement pessimistic lock getForUpdateTs
not updated(select for update, update, delete operations), ths "async rollback" risk still exists, how should we process the error here?
Or maybe we make rollback sync for "nowait" locked error?
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.
sync rollback may still send duplicated requests later.
store/tikv/2pc.go
Outdated
@@ -112,6 +112,8 @@ type twoPhaseCommitter struct { | |||
regionTxnSize map[uint64]int | |||
// Used by pessimistic transaction and large transaction. | |||
ttlManager | |||
// Used for select for update in ms, 0 means always wait, 1 means nowait | |||
lockWaitTime uint64 |
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 should lockWaitTime
be a struct field in twoPhaseCommitter?
begin;
select xxx for update no wait
select yyy for update // The committer is still there but `lockWaitTime` change?
commit;
How about pass lockWaitTime
as an argument?
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.
pessimisticLockSingleBatch
and other proc functions from getProcFuncByType
have the same declaration, seems need more change to pass it as a variable into NewRequest
call
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 did a refactoring and twoPhaseCommitAction
can carry more information now. You can see how actionPessimisticLock
is done on the master branch.
Never mind, as we can also merge the PR and refactor later.
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.
Roger, I've learned the action
refactoration when resolving conflicts, this is refactored passing time param as parameter not member of twoPhaseCommitter
still has some unstable unit tests
|
@jackysp @tiancaiamao PTAL |
/run-all-tests |
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
/release |
/run-all-tests |
@jackysp PTAL |
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
Should we wait for tikv/tikv#5680 to merge?
/release |
/run-all-tests |
/release |
This reverts commit 4b3dfce.
tikv pull requests merged, can we merge this now ? @coocood @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.
LGTM
/merge |
/run-all-tests |
What problem does this PR solve?
support select for update nowait
to implement
What is changed and how it works?
doLockKeys
interface add one new parameterlockNoWait
ErrLocked
(key locked by others)and do no more resolveLocks operations
need to discuss: how to process
forUpdateTS
bool nowait -> int waitSec to make it more flexible to support possible [wait n | nowait]
Check List
Tests
Code changes
Side effects
Related changes
Release note