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

checker: prevent the regions in split-cache from becoming the target of merge #3454

Merged
merged 3 commits into from
Mar 10, 2021

Conversation

HunDunDM
Copy link
Member

@HunDunDM HunDunDM commented Mar 4, 2021

What problem does this PR solve?

What is changed and how it works?

  • checker: prevent the regions in split-cache from becoming the target of merge

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • checker: prevent the regions in split-cache from becoming the target of merge

…of merge

Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
@HunDunDM HunDunDM added needs-cherry-pick-release-3.0 The PR needs to cherry pick to release-3.0 branch. component/checker Checker logic. type/bugfix This PR fixes a bug. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. needs-cherry-pick-5.0-rc labels Mar 4, 2021
@HunDunDM HunDunDM self-assigned this Mar 4, 2021
@HunDunDM
Copy link
Member Author

HunDunDM commented Mar 4, 2021

Originally, a unittest tested this bug, but due to many problems in the test code, the unittest failed to detect the bug.

@@ -122,8 +122,8 @@ func (s *testMergeCheckerSuite) SetUpTest(c *C) {
},
},
&metapb.Peer{Id: 109, StoreId: 4},
core.SetApproximateSize(10),
core.SetApproximateKeys(10),
core.SetApproximateSize(1),
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, the original value 10 is greater than threshold 2, which causes the region to be unable to be merged.

@@ -191,10 +191,19 @@ func (s *testMergeCheckerSuite) TestBasic(c *C) {
c.Assert(ops, NotNil)
c.Assert(ops[0].RegionID(), Equals, s.regions[2].GetID())
c.Assert(ops[1].RegionID(), Equals, s.regions[1].GetID())
s.cluster.RuleManager.DeleteRule("test", "test")
s.cluster.RuleManager.DeleteRule("pd", "test")
Copy link
Member Author

Choose a reason for hiding this comment

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

The rule was not deleted correctly here, which caused the subsequent test to be invalid.

ops = s.mc.Check(s.regions[2])
c.Assert(ops, IsNil)

s.mc.startTime = time.Now().Add(-2 * time.Hour)
Copy link
Member Author

Choose a reason for hiding this comment

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

The original test did not modify the startTime. Due to the following code logic, all regions cannot be merged.

	expireTime := m.startTime.Add(m.opts.GetSplitMergeInterval())
	if time.Now().Before(expireTime) {
		checkerCounter.WithLabelValues("merge_checker", "recently-start").Inc()
		return nil
	}

@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #3454 (e1360d7) into master (0e15869) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3454      +/-   ##
==========================================
- Coverage   75.00%   74.87%   -0.13%     
==========================================
  Files         244      244              
  Lines       23556    23557       +1     
==========================================
- Hits        17667    17638      -29     
- Misses       4311     4331      +20     
- Partials     1578     1588      +10     
Flag Coverage Δ
unittests 74.87% <100.00%> (-0.13%) ⬇️

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

Impacted Files Coverage Δ
server/schedule/checker/merge_checker.go 75.86% <100.00%> (+3.76%) ⬆️
server/tso/global_allocator.go 70.14% <0.00%> (-6.72%) ⬇️
server/tso/allocator_manager.go 72.75% <0.00%> (-4.49%) ⬇️
pkg/dashboard/adapter/manager.go 80.43% <0.00%> (-4.35%) ⬇️
server/member/member.go 68.47% <0.00%> (-2.72%) ⬇️
server/grpc_service.go 57.26% <0.00%> (-1.17%) ⬇️
server/core/storage.go 67.68% <0.00%> (-0.77%) ⬇️
server/cluster/cluster.go 83.13% <0.00%> (-0.49%) ⬇️
server/server.go 71.98% <0.00%> (ø)
server/handler.go 42.46% <0.00%> (+0.49%) ⬆️
... and 5 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 0e15869...53907c4. Read the comment docs.

@HunDunDM HunDunDM requested a review from nolouch March 4, 2021 18:33
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 5, 2021
Copy link
Contributor

@Yisaer Yisaer 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
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • lhy1024

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 5, 2021
@Yisaer
Copy link
Contributor

Yisaer commented Mar 5, 2021

/merge

@ti-chi-bot
Copy link
Member

@Yisaer: 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: c1c1e95

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 5, 2021
@lhy1024
Copy link
Contributor

lhy1024 commented Mar 5, 2021

/merge

@ti-chi-bot
Copy link
Member

@lhy1024: 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

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

At the same time I will also trigger all tests for you:

/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.

@lhy1024
Copy link
Contributor

lhy1024 commented Mar 5, 2021

/run-integration-ddl-test

1 similar comment
@HunDunDM
Copy link
Member Author

HunDunDM commented Mar 5, 2021

/run-integration-ddl-test

@HunDunDM
Copy link
Member Author

HunDunDM commented Mar 8, 2021

/run-integration-ddl-test

@HunDunDM
Copy link
Member Author

HunDunDM commented Mar 8, 2021

/run-integration-lightning-test

@Rustin170506
Copy link
Member

/run-integration-lightning-test

I think maybe this CI broken.

@Rustin170506
Copy link
Member

/run-integration-lightning-test

Or only "run-all-tests" can trigger it.

@Rustin170506
Copy link
Member

/run-all-tests

@nolouch
Copy link
Contributor

nolouch commented Mar 9, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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.

@nolouch
Copy link
Contributor

nolouch commented Mar 9, 2021

/run-integration-ddl-test

@nolouch
Copy link
Contributor

nolouch commented Mar 9, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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.

@nolouch
Copy link
Contributor

nolouch commented Mar 10, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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.

@nolouch nolouch merged commit 722a665 into tikv:master Mar 10, 2021
ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Mar 10, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-3.0 in PR #3458

ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Mar 10, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #3459

@HunDunDM HunDunDM deleted the split-protection branch March 10, 2021 04:58
ti-chi-bot pushed a commit that referenced this pull request Mar 10, 2021
…of merge (#3454) (#3459)

* cherry pick #3454 to release-4.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix

Signed-off-by: HunDunDM <hundundm@gmail.com>

Co-authored-by: 混沌DM <hundundm@gmail.com>
ti-chi-bot added a commit that referenced this pull request Mar 11, 2021
…of merge (#3454) (#3458)

* cherry pick #3454 to release-3.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* revert

Signed-off-by: HunDunDM <hundundm@gmail.com>

* pick

Signed-off-by: HunDunDM <hundundm@gmail.com>

Co-authored-by: 混沌DM <hundundm@gmail.com>
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/checker Checker logic. needs-cherry-pick-release-3.0 The PR needs to cherry pick to release-3.0 branch. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants