-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
lightning: make pre-check output message clearer (#30439) #30888
Merged
ti-chi-bot
merged 12 commits into
pingcap:release-5.3
from
ti-srebot:release-5.3-eb6c89d6d404
Feb 18, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cdbab20
cherry pick #30439 to release-5.3
glorv 8a68416
remove useless test
glorv 61fb532
fmt code
glorv 37a0b4d
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot 59f3ec3
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot aba7ea6
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot 69a26b2
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot c717e01
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot 482000d
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot 27a0567
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot 7ac134d
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
ti-chi-bot f8a24e4
Merge branch 'release-5.3' into release-5.3-eb6c89d6d404
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,80 @@ | ||
// Copyright 2021 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, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package restore | ||
|
||
import ( | ||
"context" | ||
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/failpoint" | ||
|
||
"github.com/pingcap/tidb/br/pkg/lightning/config" | ||
"github.com/pingcap/tidb/br/pkg/lightning/worker" | ||
"github.com/pingcap/tidb/br/pkg/storage" | ||
) | ||
|
||
var _ = Suite(&checkInfoSuite{}) | ||
|
||
type checkInfoSuite struct{} | ||
|
||
func (s *checkInfoSuite) TestLocalResource(c *C) { | ||
dir := c.MkDir() | ||
mockStore, err := storage.NewLocalStorage(dir) | ||
c.Assert(err, IsNil) | ||
|
||
err = failpoint.Enable("github.com/pingcap/tidb/br/pkg/lightning/common/GetStorageSize", "return(2048)") | ||
c.Assert(err, IsNil) | ||
defer func() { | ||
_ = failpoint.Disable("github.com/pingcap/tidb/br/pkg/lightning/common/GetStorageSize") | ||
}() | ||
|
||
cfg := config.NewConfig() | ||
cfg.Mydumper.SourceDir = dir | ||
cfg.TikvImporter.SortedKVDir = dir | ||
cfg.TikvImporter.Backend = "local" | ||
rc := &Controller{ | ||
cfg: cfg, | ||
store: mockStore, | ||
ioWorkers: worker.NewPool(context.Background(), 1, "io"), | ||
} | ||
|
||
// 1. source-size is smaller than disk-size, won't trigger error information | ||
rc.checkTemplate = NewSimpleTemplate() | ||
err = rc.localResource(1000) | ||
c.Assert(err, IsNil) | ||
tmpl := rc.checkTemplate.(*SimpleTemplate) | ||
c.Assert(tmpl.warnFailedCount, Equals, 1) | ||
c.Assert(tmpl.criticalFailedCount, Equals, 0) | ||
c.Assert(tmpl.normalMsgs[1], Matches, "local disk resources are rich, estimate sorted data size 1000B, local available is 2KiB") | ||
|
||
// 2. source-size is bigger than disk-size, with default disk-quota will trigger a critical error | ||
rc.checkTemplate = NewSimpleTemplate() | ||
err = rc.localResource(4096) | ||
c.Assert(err, IsNil) | ||
tmpl = rc.checkTemplate.(*SimpleTemplate) | ||
c.Assert(tmpl.warnFailedCount, Equals, 1) | ||
c.Assert(tmpl.criticalFailedCount, Equals, 1) | ||
c.Assert(tmpl.criticalMsgs[0], Matches, "local disk space may not enough to finish import, estimate sorted data size is 4KiB, but local available is 2KiB, please set `tikv-importer.disk-quota` to a smaller value than 2KiB or change `mydumper.sorted-kv-dir` to another disk with enough space to finish imports") | ||
|
||
// 3. source-size is bigger than disk-size, with a vaild disk-quota will trigger a warning | ||
rc.checkTemplate = NewSimpleTemplate() | ||
rc.cfg.TikvImporter.DiskQuota = config.ByteSize(1024) | ||
err = rc.localResource(4096) | ||
c.Assert(err, IsNil) | ||
tmpl = rc.checkTemplate.(*SimpleTemplate) | ||
c.Assert(tmpl.warnFailedCount, Equals, 1) | ||
c.Assert(tmpl.criticalFailedCount, Equals, 0) | ||
c.Assert(tmpl.normalMsgs[1], Matches, "local disk space may not enough to finish import, estimate sorted data size is 4KiB, but local available is 2KiB,we will use disk-quota \\(size: 1KiB\\) to finish imports, which may slow down import") | ||
} |
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
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.
need fix imports