-
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
store: add rateLimiter into txn commit batch actions #11817
Conversation
store/tikv/2pc.go
Outdated
@@ -115,6 +115,13 @@ type twoPhaseCommitter struct { | |||
regionTxnSize map[uint64]int | |||
} | |||
|
|||
// taskProcessor add rateLimiter to control concurrency of txn 2pc | |||
type taskProcessor struct { |
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 think batchExecutor
is a better name.
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 put more attributes in it, so we can reduce the argument count of process
and startWorker
.
store/tikv/2pc.go
Outdated
rateLimiter *rateLimit | ||
} | ||
|
||
type procFunc func(bo *Backoffer, batch batchKeys) 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.
There is already singleBatchActionFunc
defined in doActionOnBatches
. We can move it here.
// process will start worker routine and collect results | ||
func (tp *taskProcessor) process(committer *twoPhaseCommitter, procFn procFunc, | ||
bo *Backoffer, action twoPhaseCommitAction, batches []batchKeys) error { | ||
var err 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.
We can move all the logic in doActionOnBatches
here.
Codecov Report
@@ Coverage Diff @@
## master #11817 +/- ##
===========================================
Coverage 81.5518% 81.5518%
===========================================
Files 438 438
Lines 95630 95630
===========================================
Hits 77988 77988
Misses 12166 12166
Partials 5476 5476 |
…this struct instead of func params
LGTM |
@jackysp @lysu @tiancaiamao PTAL |
@cfzjywxk maybe take care twoPhaseCommitter retry logic. for example, 1 prewrite request will be div into 4 group will put into Line 481 in 3ea5ba8
|
@lysu @jackysp I'm considering set some variable in or just let retry requests processed in the same routine sequentially and do not create workers for it? PTAL any better ideas, thx |
/run-all-tests |
/run-unit-test |
/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
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
Your auto merge job has been accepted, waiting for #11886 |
/run-all-tests |
What problem does this PR solve?
Sub task of supporting
LargeTxn
for TiDB.(LargeTxn commiter not implemented yet)Tiny refactor to add concurrency control for processing batchkeys
Use same rateLimiter implementation as in copIterator like
tidb_index_serial_scan_concurrency
,tidb_distsql_scan_concurrency
usage.This may not be the final selection, some more detailed info about rate limit is described in issue document, some questions listed below(same with in the issue doc),
LargeTxn
commiter better?the usage and parameters of
batchExecutor
will be adjusted with followingLargeTxn
related changesWhat is changed and how it works?
Check List
Code changes
Side effects
Related changes