-
Notifications
You must be signed in to change notification settings - Fork 6.2k
import: check table empty skips using index #39604
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bccc7ee
import: check table empty skips using index
dsdashun 59da153
Merge branch 'master' into fix-39477
dsdashun 3551571
fix unit-tests
dsdashun 7ebf3c3
Merge remote-tracking branch 'origin/master' into fix_empty_check
dsdashun c0e0c3c
update the test data to be reproducable
dsdashun 85052b1
Merge remote-tracking branch 'origin/master' into fix_empty_check
dsdashun 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| [tikv-importer] | ||
| backend = "local" | ||
|
|
||
| [mydumper.csv] | ||
| header = true |
12 changes: 12 additions & 0 deletions
12
br/tests/lightning_check_partial_imported/data/db01.tbl01-schema.sql
This file contains hidden or 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,12 @@ | ||
| CREATE TABLE tbl01 ( | ||
| `id` INTEGER, | ||
| `val` VARCHAR(64), | ||
| `aaa` CHAR(66) DEFAULT NULL, | ||
| `bbb` CHAR(10) NOT NULL, | ||
| `ccc` CHAR(42) DEFAULT NULL, | ||
| `ddd` CHAR(42) DEFAULT NULL, | ||
| `eee` CHAR(66) DEFAULT NULL, | ||
| `fff` VARCHAR(128) DEFAULT NULL, | ||
| KEY `aaa` (`aaa`), | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; |
6 changes: 6 additions & 0 deletions
6
br/tests/lightning_check_partial_imported/data/db01.tbl01.csv
This file contains hidden or 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,6 @@ | ||
| id,val,aaa,bbb,ccc,ddd,eee,fff | ||
| 1,"v01","a01","b01","c01","d01","e01","f01" | ||
| 2,"v02","a02","b02","c02","d02","e02","f02" | ||
| 3,"v03","a03","b03","c03","d03","e03","f03" | ||
| 4,"v04","a04","b04","c04","d04","e04","f04" | ||
| 5,"v05","a05","b05","c05","d05","e05","f05" |
This file contains hidden or 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,47 @@ | ||
| #!/bin/bash | ||
| # | ||
| # 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, | ||
| # 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. | ||
|
|
||
| MYDIR=$(dirname "${BASH_SOURCE[0]}") | ||
| set -eux | ||
|
|
||
| check_cluster_version 4 0 0 'local backend' || exit 0 | ||
|
|
||
| export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/lightning/restore/FailBeforeStartImportingIndexEngine=return" | ||
| set +e | ||
| if run_lightning; then | ||
| echo "The first import doesn't fail as expected" >&2 | ||
| exit 1 | ||
| fi | ||
| set -e | ||
|
|
||
| data_records=$(tail -n +2 "${MYDIR}/data/db01.tbl01.csv" | wc -l | xargs echo ) | ||
| run_sql "SELECT COUNT(*) FROM db01.tbl01 USE INDEX();" | ||
| check_contains "${data_records}" | ||
|
|
||
| export GO_FAILPOINTS="" | ||
| set +e | ||
| if run_lightning --check-requirements=1; then | ||
| echo "The pre-check doesn't find out the non-empty table problem" | ||
| exit 2 | ||
| fi | ||
| set -e | ||
|
|
||
| run_sql "TRUNCATE TABLE db01.tbl01;" | ||
| run_lightning --check-requirements=1 | ||
| run_sql "SELECT COUNT(*) FROM db01.tbl01;" | ||
| check_contains "${data_records}" | ||
| run_sql "SELECT COUNT(*) FROM db01.tbl01 USE INDEX();" | ||
| check_contains "${data_records}" |
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.
it's still possible that index data in partially imported.
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.
If index data is partially imported, table-empty check will report errors on the second import even if
USE INDEX()is not used. So it will be figured out by the current table-empty-check logic.