forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore: dump errors while importing each table into the log at the e…
…nd (pingcap#74) * restore: dump errors while importing each table into the log at the end * restore: addressed comments to pingcap#74
- Loading branch information
Showing
10 changed files
with
109 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[lightning] | ||
check-requirements = false | ||
file = "/tmp/lightning_test_result/lightning-error-summary.log" | ||
level = "info" | ||
|
||
[checkpoint] | ||
enable = false | ||
|
||
[tikv-importer] | ||
addr = "127.0.0.1:8808" | ||
|
||
[mydumper] | ||
data-source-dir = "tests/error_summary/data" | ||
|
||
[tidb] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
status-port = 10080 | ||
pd-addr = "127.0.0.1:2379" | ||
log-level = "error" | ||
|
||
[post-restore] | ||
checksum = true | ||
compact = false | ||
analyze = false |
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 @@ | ||
CREATE DATABASE error_summary; |
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,4 @@ | ||
CREATE TABLE a( | ||
id INT NOT NULL PRIMARY KEY, | ||
k INT NOT NULL | ||
); |
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 @@ | ||
INSERT INTO a (id, k) VALUES (2, 3), (5, 7); |
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,4 @@ | ||
CREATE TABLE b( | ||
id INT NOT NULL PRIMARY KEY, | ||
k INT NOT NULL | ||
); |
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 @@ | ||
INSERT INTO b (id, k) VALUES (11, 13), (17, 19); |
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,4 @@ | ||
CREATE TABLE c( | ||
id INT NOT NULL PRIMARY KEY, | ||
k INT NOT NULL | ||
); |
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 @@ | ||
INSERT INTO c VALUES (10, 100), (1000, 10000); |
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,30 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# Check that error summary are written at the bottom of import. | ||
|
||
# The easiest way to induce error is to prepopulate the target table with conflicting content. | ||
run_sql 'CREATE DATABASE IF NOT EXISTS error_summary;' | ||
run_sql 'DROP TABLE IF EXISTS error_summary.a;' | ||
run_sql 'DROP TABLE IF EXISTS error_summary.c;' | ||
run_sql 'CREATE TABLE error_summary.a (id INT NOT NULL PRIMARY KEY, k INT NOT NULL);' | ||
run_sql 'CREATE TABLE error_summary.c (id INT NOT NULL PRIMARY KEY, k INT NOT NULL);' | ||
run_sql 'INSERT INTO error_summary.a VALUES (2, 4), (6, 8);' | ||
run_sql 'INSERT INTO error_summary.c VALUES (3, 9), (27, 81);' | ||
|
||
set +e | ||
run_lightning | ||
set -e | ||
|
||
# Verify that table `b` is indeed imported | ||
run_sql 'SELECT sum(id), sum(k) FROM error_summary.b' | ||
check_contains 'sum(id): 28' | ||
check_contains 'sum(k): 32' | ||
|
||
# Verify the log contains the expected messages at the last few lines | ||
tail -10 "$TEST_DIR/lightning-error-summary.log" > "$TEST_DIR/lightning-error-summary.tail" | ||
grep -Fq '[error] Totally **2** tables failed to be imported.' "$TEST_DIR/lightning-error-summary.tail" | ||
grep -Fq '[`error_summary`.`a`] [checksum] checksum mismatched' "$TEST_DIR/lightning-error-summary.tail" | ||
grep -Fq '[`error_summary`.`c`] [checksum] checksum mismatched' "$TEST_DIR/lightning-error-summary.tail" | ||
! grep -Fq '[`error_summary`.`b`] [checksum] checksum mismatched' "$TEST_DIR/lightning-error-summary.tail" |