-
Notifications
You must be signed in to change notification settings - Fork 289
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
kv/client: add incremental scan region count limit #1899
kv/client: add incremental scan region count limit #1899
Conversation
/run-all-tests |
1 similar comment
/run-all-tests |
/run-integration-tests |
Codecov Report
@@ Coverage Diff @@
## master #1899 +/- ##
================================================
+ Coverage 53.4083% 54.2173% +0.8089%
================================================
Files 154 161 +7
Lines 16166 16764 +598
================================================
+ Hits 8634 9089 +455
- Misses 6608 6704 +96
- Partials 924 971 +47 |
@@ -67,6 +67,13 @@ var ( | |||
Name: "channel_size", | |||
Help: "size of each channel in kv client", | |||
}, []string{"id", "channel"}) | |||
clientRegionTokenSize = prometheus.NewGaugeVec( | |||
prometheus.GaugeOpts{ | |||
Namespace: "ticdc", |
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.
maybe extract the ticdc
kvclient
in
Namespace: "ticdc",
Subsystem: "kvclient",
to const ?
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.
Yep they are constant values, but I will not change them to constants in this PR, since too many literal constants are used in metric names, maybe in another PR we can address it
cdc/kv/token_region.go
Outdated
) | ||
|
||
const ( | ||
regionOutputChanSize = 16 |
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.
could u add more comment explain why 16, thx
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.
addressed
cdc/kv/token_region.go
Outdated
} | ||
|
||
func (r *sizedRegionRouter) Run(ctx context.Context) error { | ||
ticker := time.NewTicker(time.Millisecond * 100) |
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.
maybe defined as const also?
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.
addressed
cdc/kv/client.go
Outdated
// The channel to put the region that will be sent requests. | ||
regionCh chan singleRegionInfo | ||
regionRouter LimitRegionRouter |
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 it's not a channel anymore, could you update the comment?
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.
addressed
cdc/kv/client.go
Outdated
@@ -70,6 +70,9 @@ const ( | |||
// failed region will be reloaded via `BatchLoadRegionsWithKeyRange` API. So we | |||
// don't need to force reload region any more. | |||
regionScheduleReload = false | |||
|
|||
// defines the scan region limit for each table | |||
regionScanLimitPerTable = 40 |
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.
Is it possible to limit scan region for each store?
f3f42d4
to
97ab2f4
Compare
Can you comment on how your design is similar or different form a "cancellable semaphore"? |
The semaphore counter will be used for fast check and metric counter
|
/run-all-tests /tidb=release-5.0 /tikv=release-5.0 /pd=release-5.0 /tiflash=release-5.0 |
/run-leak-tests |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 9a07fd2
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: c01b492
|
/run-unit-tests |
/run-kafka-tests |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #1930. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #1931. |
Note pingcap#1926 has picked part of pingcap#1899, this PR picks the remaining change
Note pingcap#1926 has picked part of pingcap#1899, this PR picks the remaining change
Note pingcap#1926 has picked part of pingcap#1899, this PR picks the remaining change
Note pingcap#1926 has picked part of pingcap#1899, this PR picks the remaining change
What problem does this PR solve?
This PR adds a token limiter to kv client, in order to control the concurrency of incremental scan region, for some reasons:
What is changed and how it works?
dispatchRequest
intorequestRegionToStore
dispatchRequest
only readssingleRegionInfo
from region channel, try to get gRPC context and sends thesingleRegionInfo
(which has been filled in with gRPC context) into region routerrequestRegionToStore
readssingleRegionInfo
from the output channel of region based region router, and sends real gRPC request to TiKV store.Check List
Tests
Related changes
Release note