-
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: check hasDupe and tableID when resolve duplicate rows #40696
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
af9385c
lightning: check hasDupe and tableID when resolve duplicate rows
sleepymole e3bfc4b
Merge branch 'master' into issue-40657
sleepymole f7622c4
Merge branch 'master' into issue-40657
sleepymole e49859b
Update br/tests/lightning_issue_40657/run.sh
sleepymole 733aeff
Merge branch 'master' into issue-40657
sleepymole 734f019
fix integration test
sleepymole e065f43
fix lightning_reload_cert test
sleepymole bb5624f
Merge branch 'master' into issue-40657
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[tikv-importer] | ||
backend = "local" | ||
duplicate-resolution = "remove" | ||
|
||
[mydumper.csv] | ||
header = true |
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,6 @@ | ||
CREATE TABLE `t` ( | ||
`id` int(11) NOT NULL, | ||
`name` varchar(255) DEFAULT NULL, | ||
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */, | ||
UNIQUE KEY `uni_name` (`name`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; |
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,6 @@ | ||
id,name | ||
1,"aaa01" | ||
2,"aaa02" | ||
3,"aaa03" | ||
4,"aaa04" | ||
5,"aaa04" |
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,6 @@ | ||
CREATE TABLE `t` ( | ||
`id` int(11) NOT NULL, | ||
`name` varchar(255) DEFAULT NULL, | ||
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */, | ||
UNIQUE KEY `uni_name` (`name`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; |
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,6 @@ | ||
id,name | ||
1,"aaa01" | ||
2,"aaa02" | ||
3,"aaa03" | ||
4,"aaa04" | ||
5,"aaa05" |
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,32 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2023 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. | ||
|
||
set -eux | ||
|
||
check_cluster_version 5 2 0 'duplicate detection' || exit 0 | ||
|
||
run_lightning -d "tests/$TEST_NAME/data1" | ||
run_sql 'admin check table test.t' | ||
run_sql 'select count(*) from test.t' | ||
check_contains 'count(*): 3' | ||
run_sql 'select count(*) from lightning_task_info.conflict_error_v1' | ||
check_contains 'count(*): 2' | ||
|
||
run_sql 'truncate table test.t' | ||
run_lightning -d "tests/$TEST_NAME/data2" | ||
run_sql 'admin check table test.t' | ||
run_sql 'select count(*) from test.t' | ||
check_contains 'count(*): 5' |
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.
If it's not urgent to fix, can we add more information to conflict_error_v1 and other coordination tables like taskID, taskStartTime to filter the outdated duplicated records?
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.
This fix will be cherry-picked to the released version like v6.5. It's better not to change the table schema.
Although lightning records self-task ID, it's difficult to determine whether the records are inserted by other lightning instances during parallel import or just by a previous import.
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.
Seems we also can't easily distinguish outdated conflict_error_v1 records in precheck, because it may belong to a parellel import instance?
We rely on the specific way to clean up data too much. If the user choose batch delete to clean the table for some reason (though it's almost impossible), this check will not work. But I also can't find another fix so almost lgtm.
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.
Yes.
Currently, duplicate detection doesn't work with increment import well. That is to say if users perform CRUD operations on the target table. Lightning's duplicate detection even may fail or return wrong results. For this scenario, there is still much work to do.