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

copr: split copr requests by buckets #32818

Merged
merged 14 commits into from
Mar 11, 2022
Merged

Conversation

youjiali1995
Copy link
Contributor

@youjiali1995 youjiali1995 commented Mar 4, 2022

Signed-off-by: youjiali1995 zlwgx1023@gmail.com

What problem does this PR solve?

Issue Number: close #32968

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

Documentation

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 4, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • sticnarf

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Mar 4, 2022
@ti-chi-bot
Copy link
Member

@youjiali1995: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 4, 2022
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
…cket

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995
Copy link
Contributor Author

/run-unit-test

@youjiali1995 youjiali1995 marked this pull request as ready for review March 9, 2022 10:13
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 9, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Mar 9, 2022

@youjiali1995
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 9, 2022
@@ -180,7 +181,8 @@ func buildCopTasks(bo *Backoffer, cache *RegionCache, ranges *KeyRanges, req *kv

rangesLen := ranges.Len()

locs, err := cache.SplitKeyRangesByLocations(bo, ranges)
// TODO(youjiali1995): is there any request type that needn't be splitted by buckets?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the split affect some internal work such as br cheksum, data analyze or statistic update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they should be splitted by buckets too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does TiFlash ignore buckets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. TiFlash has implemented server-side streaming by BatchCoprocessor which splits ranges by segments.

}

func TestBuildTasksByBuckets(t *testing.T) {
mockClient, cluster, pdClient, err := testutils.NewMockTiKV("", nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the new mockstore(NewMockStore) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, NewMockStore doesn't export region schedule functions.

Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SplitKeyRangesByLocations and splitKeyRangesByBuckets share the similar structure because a bucket is just like a region in region. Is it possible to unify them?

@@ -319,7 +322,6 @@ type copIteratorWorker struct {

replicaReadSeed uint32

actionOnExceed *rateLimitAction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it confirmed to be never used in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, but it's not used now.

region tikv.RegionVerID
ranges *KeyRanges
region tikv.RegionVerID
bucketsVer uint64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will it be used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget it... Now it's used for reducing UpdateBucketsIfNeeded 0b24a84#diff-23eb1043649369d5956b123b173b799ded8c6b7cbf4519bb32cb3caa01928d75R935.

store/copr/region_cache.go Outdated Show resolved Hide resolved
@@ -180,7 +181,8 @@ func buildCopTasks(bo *Backoffer, cache *RegionCache, ranges *KeyRanges, req *kv

rangesLen := ranges.Len()

locs, err := cache.SplitKeyRangesByLocations(bo, ranges)
// TODO(youjiali1995): is there any request type that needn't be splitted by buckets?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does TiFlash ignore buckets?

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

store/copr/region_cache.go Outdated Show resolved Hide resolved
var i int
for ; i < ranges.Len(); i++ {
r := ranges.At(i)
if !(bucket.Contains(r.EndKey) || bytes.Equal(bucket.EndKey, r.EndKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a simple bytes.Compare(r.EndKey, bucket.EndKey) > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be len(bucket.EndKey) != 0 && bytes.Compare(r.EndKey, bucket.EndKey) > 0. It's not simpler.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 10, 2022
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Copy link
Contributor

@cfzjywxk cfzjywxk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 11, 2022
@youjiali1995
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: dc0981c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 11, 2022
@youjiali1995
Copy link
Contributor Author

/run-unit-test

@youjiali1995
Copy link
Contributor Author

/merge

@youjiali1995
Copy link
Contributor Author

/merge

@youjiali1995
Copy link
Contributor Author

/run-unit-test

@ti-chi-bot ti-chi-bot merged commit 328a8bc into pingcap:master Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

split copr requests by buckets
5 participants