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

cluster: handle region after report split #6867

Merged
merged 26 commits into from
Sep 21, 2023

Conversation

bufferflies
Copy link
Contributor

@bufferflies bufferflies commented Jul 31, 2023

Signed-off-by: bufferflies [email protected]

What problem does this PR solve?

Issue Number: close #4157 and close tikv/tikv#15210

What is changed and how it works?

put region after batch report split

Check List

Tests

  • Unit test
  • Manual test
// test sql
use test;drop table if exists t2;create table t2 (a int, b varchar(10), unique index idx_a(a)) partition by hash (a) partitions 3;insert into t2 values (1,'a'), (11, 'h'), (22, 'o');show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2
regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;show table t2 regions;


no any err `PD returned no region`

Code changes

Side effects

Related changes

Release note

handle region after report split

Signed-off-by: bufferflies <[email protected]>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jul 31, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • HuSharp

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 bot added do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 31, 2023
@ti-chi-bot ti-chi-bot bot requested review from nolouch and rleungx July 31, 2023 11:16
@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 31, 2023
@CabinfeverB CabinfeverB self-requested a review August 2, 2023 03:16
Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

ci failed

server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/cluster/cluster_worker.go Outdated Show resolved Hide resolved
server/cluster/cluster.go Outdated Show resolved Hide resolved
Copy link
Member

@CabinfeverB CabinfeverB left a comment

Choose a reason for hiding this comment

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

Can we add some comment to show the difference processRegionSplit needs to do less than processRegionHeartbeat

server/cluster/cluster.go Outdated Show resolved Hide resolved
server/cluster/cluster.go Outdated Show resolved Hide resolved
continue
}
// region split initiator store will be leader with a high probability
leader := region.Peers[0]
Copy link
Member

Choose a reason for hiding this comment

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

Will it cause the balance leader to wrong place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch.

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 will mark this store as split store and balance region scheduler doesn't pick this store as target store.

server/cluster/cluster_worker.go Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
Signed-off-by: bufferflies <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 7, 2023
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #6867 (8df5867) into master (925181c) will increase coverage by 0.19%.
The diff coverage is 86.11%.

❗ Current head 8df5867 differs from pull request most recent head 697d100. Consider uploading reports for the commit 697d100 to get more accurate results

@@            Coverage Diff             @@
##           master    #6867      +/-   ##
==========================================
+ Coverage   74.29%   74.48%   +0.19%     
==========================================
  Files         440      440              
  Lines       47150    47195      +45     
==========================================
+ Hits        35030    35154     +124     
+ Misses       9022     8969      -53     
+ Partials     3098     3072      -26     
Flag Coverage Δ
unittests 74.48% <86.11%> (+0.19%) ⬆️

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

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 10, 2023
Copy link
Member

@CabinfeverB CabinfeverB left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -486,7 +486,8 @@ func (l *balanceLeaderScheduler) transferLeaderOut(solver *solver, collector *pl
// the worst follower peer and transfers the leader.
func (l *balanceLeaderScheduler) transferLeaderIn(solver *solver, collector *plan.Collector) *operator.Operator {
solver.Region = filter.SelectOneRegion(solver.RandFollowerRegions(solver.TargetStoreID(), l.conf.Ranges),
nil, filter.NewRegionPendingFilter(), filter.NewRegionDownFilter())
nil, filter.NewRegionPendingFilter(), filter.NewRegionDownFilter(),
filter.NewStoreRecentlySplitFilter(solver.GetStores()))
Copy link
Member

Choose a reason for hiding this comment

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

we can avoid to create a new filter every time

@@ -184,6 +183,7 @@ func newBalanceLeaderScheduler(opController *operator.Controller, conf *balanceL
&filter.StoreStateFilter{ActionScope: s.GetName(), TransferLeader: true, ForbidRecentlySplitRegions: true, OperatorLevel: constant.High},
filter.NewSpecialUseFilter(s.GetName()),
}
s.regionFilters = filter.NewStoreRecentlySplitFilter(opController.GetCluster().GetStores())
Copy link
Member

Choose a reason for hiding this comment

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

It should be created in Schedule()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch , has fixed

changed := &core.RegionChanged{
IsNew: true, SaveKV: true, SaveCache: true, NeedSync: true,
}
if err := c.SaveRegion(region, changed); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the new split region has been heartbeat to pd then the receive the report split? I think we need check the chagned should it be saved.

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 can't be hapend. Tikv send this request before the region init.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bufferflies network is unexpected. and they are not in the same stream.

@CabinfeverB
Copy link
Member

/run-check-issue-triage-complete

@CabinfeverB CabinfeverB removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 20, 2023
Signed-off-by: bufferflies <[email protected]>
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 20, 2023
@HuSharp
Copy link
Member

HuSharp commented Sep 20, 2023

please fixed GenerateRegionGuideFunc in server/cluster.go

Signed-off-by: bufferflies <[email protected]>
@bufferflies
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 21, 2023

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

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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
Contributor

ti-chi-bot bot commented Sep 21, 2023

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

Commit hash: 8df5867

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 21, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 21, 2023

@bufferflies: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-chi-bot bot merged commit a997316 into tikv:master Sep 21, 2023
19 checks passed
@bufferflies bufferflies deleted the region_info branch September 21, 2023 02:36
rleungx added a commit to rleungx/pd that referenced this pull request Sep 22, 2023
rleungx added a commit to rleungx/pd that referenced this pull request Sep 22, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. 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
6 participants