-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ddl_manager (ticdc): Fix a panic in ddlManager. (#8716)
close #8714
- Loading branch information
1 parent
3554e47
commit 0d82a60
Showing
6 changed files
with
222 additions
and
14 deletions.
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,28 @@ | ||
# diff Configuration. | ||
check-thread-count = 4 | ||
|
||
export-fix-sql = true | ||
|
||
check-struct-only = false | ||
|
||
[task] | ||
output-dir = "/tmp/tidb_cdc_test/ddl_manager/sync_diff/output" | ||
|
||
source-instances = ["mysql1"] | ||
|
||
target-instance = "tidb0" | ||
|
||
target-check-tables = ["ddl_manager.*"] | ||
|
||
[data-sources] | ||
[data-sources.mysql1] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" | ||
|
||
[data-sources.tidb0] | ||
host = "127.0.0.1" | ||
port = 3306 | ||
user = "root" | ||
password = "" |
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,105 @@ | ||
drop database if exists `ddl_manager`; | ||
create database `ddl_manager`; | ||
|
||
drop database if exists `ddl_manager_test1`; | ||
create database `ddl_manager_test1`; | ||
|
||
drop database if exists `ddl_manager_test2`; | ||
create database `ddl_manager_test2`; | ||
|
||
drop database if exists `ddl_manager_test3`; | ||
create database `ddl_manager_test3`; | ||
|
||
use `ddl_manager`; | ||
|
||
create table t1 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
INSERT INTO t1 (val, col0) VALUES (1, 1); | ||
INSERT INTO t1 (val, col0) VALUES (2, 2); | ||
INSERT INTO t1 (val, col0) VALUES (3, 3); | ||
INSERT INTO t1 (val, col0) VALUES (4, 4); | ||
INSERT INTO t1 (val, col0) VALUES (5, 5); | ||
|
||
|
||
CREATE TABLE t2 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
INSERT INTO t2 (val, col0) VALUES (1, 1); | ||
INSERT INTO t2 (val, col0) VALUES (2, 2); | ||
INSERT INTO t2 (val, col0) VALUES (3, 3); | ||
INSERT INTO t2 (val, col0) VALUES (4, 4); | ||
INSERT INTO t2 (val, col0) VALUES (5, 5); | ||
|
||
drop table t2; | ||
|
||
create table t3 ( | ||
a int, primary key (a) | ||
) partition by hash(a) partitions 5; | ||
insert into t3 values (1),(2),(3),(4),(5),(6); | ||
insert into t3 values (7),(8),(9); | ||
alter table t3 truncate partition p3; | ||
|
||
create table t4 (a int primary key) PARTITION BY RANGE ( a ) ( PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (21)); | ||
insert into t4 values (1),(2),(3),(4),(5),(6); | ||
insert into t4 values (7),(8),(9); | ||
insert into t4 values (11),(12),(20); | ||
alter table t4 add partition (partition p3 values less than (30), partition p4 values less than (40)); | ||
|
||
CREATE TABLE t5 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
CREATE TABLE t6 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
DROP TABLE t5; | ||
|
||
drop database if exists `ddl_manager_test2`; | ||
|
||
CREATE TABLE t7 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
DROP TABLE t6; | ||
|
||
CREATE TABLE t8 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
DROP TABLE t7; | ||
|
||
CREATE TABLE t9 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
DROP TABLE t8; | ||
|
||
CREATE TABLE t10 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
|
||
DROP TABLE t9; | ||
|
||
CREATE TABLE finish_mark ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 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,53 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
source $CUR/../_utils/test_prepare | ||
WORK_DIR=$OUT_DIR/$TEST_NAME | ||
CDC_BINARY=cdc.test | ||
SINK_TYPE=$1 | ||
|
||
function run() { | ||
rm -rf $WORK_DIR && mkdir -p $WORK_DIR | ||
|
||
start_tidb_cluster --workdir $WORK_DIR | ||
|
||
cd $WORK_DIR | ||
|
||
export GO_FAILPOINTS='github.com/pingcap/tiflow/cdc/owner/ExecuteDDLSlowly=return(true)' | ||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY | ||
owner_pid=$(ps -C $CDC_BINARY -o pid= | awk '{print $1}') | ||
|
||
# this test contains `recover table`, which requires super privilege, so we | ||
# can't use the normal user | ||
TOPIC_NAME="ticdc-ddl-mamager-test-$RANDOM" | ||
case $SINK_TYPE in | ||
kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=open-protocol&partition-num=4&kafka-version=${KAFKA_VERSION}&max-message-bytes=10485760" ;; | ||
*) SINK_URI="mysql://[email protected]:3306/" ;; | ||
esac | ||
changefeed_id="ddl-manager" | ||
run_cdc_cli changefeed create --sink-uri="$SINK_URI" -c=${changefeed_id} | ||
|
||
if [ "$SINK_TYPE" == "kafka" ]; then | ||
run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=open-protocol&partition-num=4&version=${KAFKA_VERSION}&max-message-bytes=10485760" | ||
fi | ||
|
||
run_sql_file $CUR/data/prepare.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
|
||
# kill owner to make sure ddl manager is working right when owner is down and up | ||
kill_cdc_pid $owner_pid | ||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY | ||
owner_pid=$(ps -C $CDC_BINARY -o pid= | awk '{print $1}') | ||
|
||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY | ||
check_table_exists ddl_manager.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 | ||
# make sure all tables are equal in upstream and downstream | ||
check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 180 | ||
cleanup_process $CDC_BINARY | ||
} | ||
|
||
trap stop_tidb_cluster EXIT | ||
run $* | ||
check_logs $WORK_DIR | ||
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" |