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.
fix(schema): fix DML construct error caused by 'rename tables' DDL
close pingcap#5059
- Loading branch information
1 parent
0c38e62
commit d0e85d5
Showing
6 changed files
with
142 additions
and
7 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
29 changes: 29 additions & 0 deletions
29
tests/integration_tests/rename_tables/conf/diff_config.toml
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,29 @@ | ||
# diff Configuration. | ||
|
||
check-thread-count = 4 | ||
|
||
export-fix-sql = true | ||
|
||
check-struct-only = false | ||
|
||
[task] | ||
output-dir = "/tmp/tidb_cdc_test/rename_tables/sync_diff/output" | ||
|
||
source-instances = ["tidb0"] | ||
|
||
target-instance = "mysql1" | ||
|
||
target-check-tables = ["rename_tables_test.?*"] | ||
|
||
[data-sources] | ||
[data-sources.tidb0] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" | ||
|
||
[data-sources.mysql1] | ||
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,46 @@ | ||
drop database if exists `rename_tables_test`; | ||
create database `rename_tables_test`; | ||
use `rename_tables_test`; | ||
|
||
create table t1 ( | ||
value64 bigint unsigned not null, | ||
primary key(value64) | ||
); | ||
insert into t1 values(17156792991891826145); | ||
insert into t1 values(91891826145); | ||
delete from t1 where value64=17156792991891826145; | ||
update t1 set value64=17156792991891826; | ||
update t1 set value64=56792991891826; | ||
rename table t1 to t1_1; | ||
|
||
create table t2 ( | ||
value64 bigint unsigned not null, | ||
primary key(value64) | ||
); | ||
insert into t2 values(17156792991891826145); | ||
insert into t2 values(91891826145); | ||
delete from t2 where value64=91891826145; | ||
update t2 set value64=17156792991891826; | ||
update t2 set value64=56792991891826; | ||
rename table t2 to t2_2; | ||
|
||
create table t1 ( | ||
value64 bigint unsigned not null, | ||
value32 integer not null, | ||
primary key(value64, value32) | ||
); | ||
|
||
create table t2 ( | ||
value64 bigint unsigned not null, | ||
value32 integer not null, | ||
primary key(value64, value32) | ||
); | ||
|
||
insert into t1 values(17156792991891826145, 1); | ||
insert into t1 values( 9223372036854775807, 2); | ||
insert into t2 values(17156792991891826145, 3); | ||
insert into t2 values( 9223372036854775807, 4); | ||
|
||
rename table t1 to t1_7, t2 to t2_7; | ||
|
||
create table finish_mark(id 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,48 @@ | ||
#!/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 | ||
|
||
# record tso before we create tables to skip the system table DDLs | ||
start_ts=$(cdc cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1) | ||
|
||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY | ||
|
||
TOPIC_NAME="ticdc-clustered-index-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://normal:123456@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?protocol=open-protocol&partition-num=4&version=${KAFKA_VERSION}&max-message-bytes=10485760" | ||
fi | ||
run_sql "set global tidb_enable_clustered_index=1;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
# TiDB global variables cache 2 seconds at most | ||
sleep 2 | ||
run_sql_file $CUR/data/test.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 rename_tables_test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} | ||
echo "check table exists success" | ||
check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 60 | ||
|
||
cleanup_process $CDC_BINARY | ||
} | ||
|
||
trap stop_tidb_cluster EXIT | ||
run $* | ||
check_logs $WORK_DIR | ||
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" |