forked from pingcap/tiflow
-
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.
owner: fix a bug about wrong timing sequence of DDL when add a table …
…to processor (pingcap#450)
- Loading branch information
leoppro
authored
Apr 10, 2020
1 parent
f7f9435
commit 0f4980b
Showing
6 changed files
with
126 additions
and
8 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,27 @@ | ||
# diff Configuration. | ||
|
||
log-level = "info" | ||
chunk-size = 10 | ||
check-thread-count = 4 | ||
sample-percent = 100 | ||
use-rowid = false | ||
use-checksum = true | ||
fix-sql-file = "fix.sql" | ||
|
||
# tables need to check. | ||
[[check-tables]] | ||
schema = "ddl_sequence" | ||
tables = ["~.*"] | ||
|
||
[[source-db]] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" | ||
instance-id = "source-1" | ||
|
||
[target-db] | ||
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,45 @@ | ||
drop database if exists `ddl_sequence`; | ||
create database `ddl_sequence`; | ||
use `ddl_sequence`; | ||
|
||
CREATE TABLE many_cols1 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
ALTER TABLE many_cols1 DROP COLUMN col0; | ||
INSERT INTO many_cols1 (val) VALUES (1); | ||
|
||
CREATE TABLE many_cols2 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
ALTER TABLE many_cols2 DROP COLUMN col0; | ||
INSERT INTO many_cols2 (val) VALUES (1); | ||
|
||
CREATE TABLE many_cols3 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
ALTER TABLE many_cols3 DROP COLUMN col0; | ||
INSERT INTO many_cols3 (val) VALUES (1); | ||
|
||
CREATE TABLE many_cols4 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
ALTER TABLE many_cols4 DROP COLUMN col0; | ||
INSERT INTO many_cols4 (val) VALUES (1); | ||
|
||
CREATE TABLE many_cols5 ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
val INT DEFAULT 0, | ||
col0 INT NOT NULL | ||
); | ||
ALTER TABLE many_cols5 DROP COLUMN col0; | ||
INSERT INTO many_cols5 (val) VALUES (1); | ||
|
||
CREATE TABLE finish_mark(a int primary key) |
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,43 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
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 $WORK_DIR | ||
|
||
cd $WORK_DIR | ||
|
||
# record tso before we create tables to skip the system table DDLs | ||
start_ts=$(cdc cli tso query --pd=http://$UP_PD_HOST:$UP_PD_PORT) | ||
|
||
run_cdc_server $WORK_DIR $CDC_BINARY | ||
|
||
TOPIC_NAME="ticdc-ddl-sequence-test-$RANDOM" | ||
case $SINK_TYPE in | ||
kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4";; | ||
mysql) ;& | ||
*) SINK_URI="mysql://root@127.0.0.1:3306/";; | ||
esac | ||
cdc cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" | ||
if [ "$SINK_TYPE" == "kafka" ]; then | ||
run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4" | ||
fi | ||
run_sql_file $CUR/data/prepare.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
# sync_diff can't check non-exist table, so we check expected tables are created in downstream first | ||
check_table_exists ddl_sequence.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml | ||
|
||
cleanup_process $CDC_BINARY | ||
} | ||
|
||
trap stop_tidb_cluster EXIT | ||
run $* | ||
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" |