-
Notifications
You must be signed in to change notification settings - Fork 283
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(dm): port some precheck from lightning #7617
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5f98a30
--wip-- [skip ci]
lance6716 06dbbaa
save work
lance6716 ce9fd63
finish
lance6716 1061df5
fix fmt
lance6716 fdc4793
fix lint
lance6716 6230a88
Merge branch 'master' into add-lightning-precheck
lance6716 eb6a184
Merge branch 'master' of github.com:pingcap/tiflow into add-lightning…
lance6716 a609857
Update dm/checker/checker.go
lance6716 0d952fa
Merge branch 'master' into add-lightning-precheck
ti-chi-bot 15dc4d4
change some message
lance6716 0b765db
Merge branch 'master' into add-lightning-precheck
ti-chi-bot 7db68c7
Merge branch 'master' into add-lightning-precheck
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package checker | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pingcap/tidb/br/pkg/lightning/restore" | ||
) | ||
|
||
func convertLightningPrecheck( | ||
ctx context.Context, | ||
dmResult *Result, | ||
lightningPrechecker restore.PrecheckItem, | ||
failLevel State, | ||
instruction string, | ||
) { | ||
lightningResult, err := lightningPrechecker.Check(ctx) | ||
if err != nil { | ||
markCheckError(dmResult, err) | ||
return | ||
} | ||
if !lightningResult.Passed { | ||
dmResult.State = failLevel | ||
dmResult.Instruction = instruction | ||
dmResult.Errors = append(dmResult.Errors, &Error{Severity: failLevel, ShortErr: lightningResult.Message}) | ||
return | ||
} | ||
dmResult.State = StateSuccess | ||
} | ||
|
||
// LightningEmptyRegionChecker checks whether there are too many empty regions in the cluster. | ||
type LightningEmptyRegionChecker struct { | ||
inner restore.PrecheckItem | ||
} | ||
|
||
// NewLightningEmptyRegionChecker creates a new LightningEmptyRegionChecker. | ||
func NewLightningEmptyRegionChecker(lightningChecker restore.PrecheckItem) RealChecker { | ||
return &LightningEmptyRegionChecker{inner: lightningChecker} | ||
} | ||
|
||
// Name implements the RealChecker interface. | ||
func (c *LightningEmptyRegionChecker) Name() string { | ||
return "lightning_empty_region" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. other checkers do not have same name with checking items. I'll ask PM |
||
} | ||
|
||
// Check implements the RealChecker interface. | ||
func (c *LightningEmptyRegionChecker) Check(ctx context.Context) *Result { | ||
result := &Result{ | ||
Name: c.Name(), | ||
Desc: "check whether there are too many empty Regions in the TiKV under Physical import mode", | ||
State: StateFailure, | ||
} | ||
convertLightningPrecheck( | ||
ctx, | ||
result, | ||
c.inner, | ||
StateWarning, | ||
`you can change "region merge" related configuration in PD to speed up eliminating empty regions`, | ||
) | ||
return result | ||
} | ||
|
||
// LightningRegionDistributionChecker checks whether the region distribution is balanced. | ||
type LightningRegionDistributionChecker struct { | ||
inner restore.PrecheckItem | ||
} | ||
|
||
// NewLightningRegionDistributionChecker creates a new LightningRegionDistributionChecker. | ||
func NewLightningRegionDistributionChecker(lightningChecker restore.PrecheckItem) RealChecker { | ||
return &LightningRegionDistributionChecker{inner: lightningChecker} | ||
} | ||
|
||
// Name implements the RealChecker interface. | ||
func (c *LightningRegionDistributionChecker) Name() string { | ||
return "lightning_region_distribution" | ||
} | ||
|
||
// Check implements the RealChecker interface. | ||
func (c *LightningRegionDistributionChecker) Check(ctx context.Context) *Result { | ||
result := &Result{ | ||
Name: c.Name(), | ||
Desc: "check whether the Regions in the TiKV cluster are distributed evenly under Physical import mode", | ||
State: StateFailure, | ||
} | ||
convertLightningPrecheck( | ||
ctx, | ||
result, | ||
c.inner, | ||
StateWarning, | ||
`you can change "region schedule" related configuration in PD to speed up balancing regions`, | ||
) | ||
return result | ||
} | ||
|
||
// LightningClusterVersionChecker checks whether the cluster version is compatible with Lightning. | ||
type LightningClusterVersionChecker struct { | ||
inner restore.PrecheckItem | ||
} | ||
|
||
// NewLightningClusterVersionChecker creates a new LightningClusterVersionChecker. | ||
func NewLightningClusterVersionChecker(lightningChecker restore.PrecheckItem) RealChecker { | ||
return &LightningClusterVersionChecker{inner: lightningChecker} | ||
} | ||
|
||
// Name implements the RealChecker interface. | ||
func (c *LightningClusterVersionChecker) Name() string { | ||
return "lightning_cluster_version" | ||
} | ||
|
||
// Check implements the RealChecker interface. | ||
func (c *LightningClusterVersionChecker) Check(ctx context.Context) *Result { | ||
result := &Result{ | ||
Name: c.Name(), | ||
Desc: "check whether the downstream TiDB/PD/TiKV version meets the requirements of Physical import mode", | ||
State: StateFailure, | ||
} | ||
convertLightningPrecheck( | ||
ctx, | ||
result, | ||
c.inner, | ||
StateFailure, | ||
`you can switch to logical import mode which has no requirements on downstream cluster version`, | ||
) | ||
return result | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need some checks for tidb backend?
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.
the checks in this PR is only for local backend because they are related to storage layer. I'll add more later
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.
Does DM support local backend now? 🤔
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.
#7448