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

server: pd can support bucket steam and save them. #4670

Merged
merged 23 commits into from
Apr 1, 2022

Conversation

bufferflies
Copy link
Contributor

@bufferflies bufferflies commented Feb 23, 2022

What problem does this PR solve?

Issue Number: Close #4669

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

  • Has configuration change

Side effects

Related changes

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 23, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • rleungx

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 the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Feb 23, 2022
@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #4670 (23dbb43) into master (c408535) will decrease coverage by 0.41%.
The diff coverage is 24.46%.

@@            Coverage Diff             @@
##           master    #4670      +/-   ##
==========================================
- Coverage   75.42%   75.00%   -0.42%     
==========================================
  Files         294      294              
  Lines       28334    28463     +129     
==========================================
- Hits        21371    21349      -22     
- Misses       5078     5213     +135     
- Partials     1885     1901      +16     
Flag Coverage Δ
unittests 75.00% <24.46%> (-0.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/cluster/cluster_worker.go 71.29% <0.00%> (-0.67%) ⬇️
server/core/basic_cluster.go 88.70% <0.00%> (-2.96%) ⬇️
server/grpc_service.go 50.68% <0.00%> (-5.14%) ⬇️
server/cluster/cluster.go 84.82% <86.66%> (+0.01%) ⬆️
server/cluster/metrics.go 100.00% <100.00%> (ø)
server/core/region.go 91.78% <100.00%> (+0.19%) ⬆️
server/metrics.go 100.00% <100.00%> (ø)
pkg/tempurl/tempurl.go 45.00% <0.00%> (-15.00%) ⬇️
server/tso/local_allocator.go 64.86% <0.00%> (-6.76%) ⬇️
server/tso/allocator_manager.go 62.56% <0.00%> (-4.82%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 226b25b...23dbb43. Read the comment docs.

@bufferflies bufferflies force-pushed the feature/bucket branch 5 times, most recently from cf7f152 to cdc56d9 Compare February 25, 2022 02:28
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 25, 2022
@bufferflies bufferflies changed the title draft: pd can handler bucket steam and support searching function. server: pd can handler bucket steam and support searching function. Mar 3, 2022
@bufferflies bufferflies removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Mar 3, 2022
@bufferflies bufferflies changed the title server: pd can handler bucket steam and support searching function. server: pd can support bucket steam and save them. Mar 4, 2022
@ti-chi-bot ti-chi-bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Mar 4, 2022
@bufferflies bufferflies requested a review from lhy1024 March 4, 2022 01:53
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 7, 2022
@bufferflies
Copy link
Contributor Author

PTAL @lhy1024 @rleungx

@bufferflies
Copy link
Contributor Author

/open

@bufferflies bufferflies reopened this Mar 9, 2022
@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

// HandleBucketHeartbeat processes RegionInfo reports from client
func (c *RaftCluster) HandleBucketHeartbeat(buckets *metapb.Buckets) error {
return c.processBucketHeartbeat(buckets)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this abstruction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the first, HandleBucketHeartbeat should handle the change of the bucket meta(keys and version), but in the second , it will handle the statistics.

server/core/region.go Outdated Show resolved Hide resolved
server/core/region.go Outdated Show resolved Hide resolved
@rleungx
Copy link
Member

rleungx commented Mar 10, 2022

The implementation is almost the same as region heartbeat, can we abstract the common part to reduce code?

Signed-off-by: bufferflies <1045931706@qq.com>
}

// region should not update if the version of the buckets is less than the old one.
if old := region.GetBuckets(); old != nil && old.Version >= buckets.Version {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be old.Version > buckets.Version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

region will not update if version is not change.

Copy link
Member

Choose a reason for hiding this comment

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

It seems the region heartbeat only checks < here. As for a region, the version only changes when splitting or merging happens, so it's still necessary to update other statistical information while the version remains the same. I assume a bucket should also work like that, right?

if region.GetRegionEpoch().GetVersion() < item.GetRegionEpoch().GetVersion() && !isRegionRecreated(region) {

Copy link
Member

@rleungx rleungx Mar 31, 2022

Choose a reason for hiding this comment

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

Is there a possibility that we have an ABA problem here? Consider the following case:
There are two requests coming at the same time. Both request A and request B have passed the version check, A is a little bit earlier than B. But B which has a larger version is finished earlier than A. After A is finished, B is lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems the region heartbeat only checks < here. As for a region, the version only changes when splitting or merging happens, so it's still necessary to update other statistical information while the version remains the same. I assume a bucket should also work like that, right?

if region.GetRegionEpoch().GetVersion() < item.GetRegionEpoch().GetVersion() && !isRegionRecreated(region) {

the version of the bucket maybe happened at cron job or wirte skew, so it should drop the buckets info if the version is same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a possibility that we have an ABA problem here? Consider the following case: There are two requests coming at the same time. Both request A and request B have passed the version check, A is a little bit earlier than B. But B which has a larger version is finished earlier than A. After A is finished, B is lost.

yes, the conor will be happened , I will use CAS to avoid the latest buckets to be replaced.

server/cluster/cluster_test.go Outdated Show resolved Hide resolved
server/core/region.go Outdated Show resolved Hide resolved
if r.approximateSize != 0 {
return
func (r *RegionInfo) Inherit(origin *RegionInfo) {
// regionSize should not be zero if region is not empty.
Copy link
Member

Choose a reason for hiding this comment

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

I think we can check whether the origin is nil at the beginning of this function and return directly if it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

region size will be 1 if origin is nil and the size of the new region is zero.

server/grpc_service.go Show resolved Hide resolved
server/grpc_service.go Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
Signed-off-by: bufferflies <1045931706@qq.com>
Signed-off-by: bufferflies <1045931706@qq.com>
server/cluster/cluster.go Outdated Show resolved Hide resolved
Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. And we need a concurrency test for this PR.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 31, 2022
Signed-off-by: bufferflies <1045931706@qq.com>
@bufferflies
Copy link
Contributor Author

Mostly LGTM. And we need a concurrency test for this PR.

I have added one concurrency test for ABA and one benchmark test for region update.

@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 31, 2022
@bufferflies
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@bufferflies: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

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

Commit hash: 23dbb43

@ti-chi-bot ti-chi-bot added status/can-merge Indicates a PR has been approved by a committer. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 1, 2022
@ti-chi-bot ti-chi-bot merged commit 44a8672 into tikv:master Apr 1, 2022
ti-chi-bot pushed a commit that referenced this pull request Apr 14, 2022
ref #4670, close #4749

Signed-off-by: bufferflies <1045931706@qq.com>
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. 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.

pd can handler bucket steam and support searching function.
6 participants