@@ -91,29 +91,6 @@ function run_create_table_conflict_case() {
9191 echo " [$( date) ] finish create table conflict case"
9292}
9393
94- function run_rename_table_conflict_case() {
95- local source_a=route_conflict_rename_a
96- local source_b=route_conflict_rename_b
97- local target_schema=target_route_conflict_rename
98- local changefeed_id=route-conflict-rename
99- local config_file=" $WORK_DIR /$changefeed_id .toml"
100- local start_ts
101-
102- echo " [$( date) ] start rename table conflict case"
103- write_route_config " $config_file " " $source_a " " $source_b " " $target_schema "
104- start_ts=$( run_cdc_cli_tso_query " $UP_PD_HOST_1 " " $UP_PD_PORT_1 " )
105- run_sql " CREATE DATABASE $source_a ; CREATE TABLE $source_a .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
106- run_sql " CREATE DATABASE $source_b ; CREATE TABLE $source_b .tmp (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
107- cdc_cli_changefeed create -c " $changefeed_id " --start-ts=" $start_ts " --sink-uri=" $SINK_URI " --config=" $config_file "
108- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
109- check_table_exists " $target_schema .tmp_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
110-
111- run_sql " RENAME TABLE $source_b .tmp TO $source_b .t;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
112- ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1} :${UP_PD_PORT_1} " $changefeed_id " failed conflict " "
113- cdc_cli_changefeed remove -c " $changefeed_id " || true
114- echo " [$( date) ] finish rename table conflict case"
115- }
116-
11794function run_multi_rename_table_conflict_case() {
11895 local source_a=route_conflict_multi_rename_a
11996 local source_b=route_conflict_multi_rename_b
@@ -138,107 +115,6 @@ function run_multi_rename_table_conflict_case() {
138115 echo " [$( date) ] finish multi-rename table conflict case"
139116}
140117
141- function run_drop_table_release_case() {
142- local source_a=route_conflict_drop_table_a
143- local source_b=route_conflict_drop_table_b
144- local target_schema=target_route_conflict_drop_table
145- local changefeed_id=route-conflict-drop-table
146- local config_file=" $WORK_DIR /$changefeed_id .toml"
147- local start_ts
148-
149- echo " [$( date) ] start drop table release case"
150- write_route_config " $config_file " " $source_a " " $source_b " " $target_schema "
151- start_ts=$( run_cdc_cli_tso_query " $UP_PD_HOST_1 " " $UP_PD_PORT_1 " )
152- run_sql " CREATE DATABASE $source_a ; CREATE TABLE $source_a .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
153- cdc_cli_changefeed create -c " $changefeed_id " --start-ts=" $start_ts " --sink-uri=" $SINK_URI " --config=" $config_file "
154- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
155-
156- run_sql " DROP TABLE $source_a .t;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
157- check_table_not_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
158- run_sql " CREATE DATABASE $source_b ; CREATE TABLE $source_b .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
159- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
160- ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1} :${UP_PD_PORT_1} " $changefeed_id " normal null " "
161- cdc_cli_changefeed remove -c " $changefeed_id " || true
162- echo " [$( date) ] finish drop table release case"
163- }
164-
165- function run_drop_database_release_case() {
166- local source_a=route_conflict_drop_database_a
167- local source_b=route_conflict_drop_database_b
168- local target_schema=target_route_conflict_drop_database
169- local changefeed_id=route-conflict-drop-database
170- local config_file=" $WORK_DIR /$changefeed_id .toml"
171- local start_ts
172-
173- echo " [$( date) ] start drop database release case"
174- write_route_config " $config_file " " $source_a " " $source_b " " $target_schema "
175- start_ts=$( run_cdc_cli_tso_query " $UP_PD_HOST_1 " " $UP_PD_PORT_1 " )
176- run_sql " CREATE DATABASE $source_a ; CREATE TABLE $source_a .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
177- cdc_cli_changefeed create -c " $changefeed_id " --start-ts=" $start_ts " --sink-uri=" $SINK_URI " --config=" $config_file "
178- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
179-
180- run_sql " DROP DATABASE $source_a ;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
181- check_table_not_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
182- run_sql " CREATE DATABASE $source_b ; CREATE TABLE $source_b .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
183- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
184- ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1} :${UP_PD_PORT_1} " $changefeed_id " normal null " "
185- cdc_cli_changefeed remove -c " $changefeed_id " || true
186- echo " [$( date) ] finish drop database release case"
187- }
188-
189- function run_rename_table_out_of_filter_release_case() {
190- local source_a=route_conflict_rename_out_a
191- local source_b=route_conflict_rename_out_b
192- local ignored_schema=route_conflict_rename_out_ignored
193- local target_schema=target_route_conflict_rename_out
194- local changefeed_id=route-conflict-rename-out
195- local config_file=" $WORK_DIR /$changefeed_id .toml"
196- local start_ts
197-
198- echo " [$( date) ] start rename table out of filter release case"
199- write_route_config " $config_file " " $source_a " " $source_b " " $target_schema "
200- start_ts=$( run_cdc_cli_tso_query " $UP_PD_HOST_1 " " $UP_PD_PORT_1 " )
201- run_sql " CREATE DATABASE $source_a ; CREATE TABLE $source_a .t (id INT PRIMARY KEY); CREATE DATABASE $ignored_schema ;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
202- # The old table is still in the replication range, so TiCDC writes the RENAME
203- # to downstream even though the new schema is outside the filter. Prepare the
204- # downstream schema explicitly and keep this case focused on route admission
205- # release instead of downstream schema existence.
206- run_sql " CREATE DATABASE $ignored_schema ;" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT "
207- cdc_cli_changefeed create -c " $changefeed_id " --start-ts=" $start_ts " --sink-uri=" $SINK_URI " --config=" $config_file "
208- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
209-
210- run_sql " RENAME TABLE $source_a .t TO $ignored_schema .t;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
211- check_table_not_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
212- run_sql " CREATE DATABASE $source_b ; CREATE TABLE $source_b .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
213- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
214- ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1} :${UP_PD_PORT_1} " $changefeed_id " normal null " "
215- cdc_cli_changefeed remove -c " $changefeed_id " || true
216- echo " [$( date) ] finish rename table out of filter release case"
217- }
218-
219- function run_truncate_table_keeps_source_name_case() {
220- local source_a=route_conflict_truncate_a
221- local source_b=route_conflict_truncate_b
222- local target_schema=target_route_conflict_truncate
223- local changefeed_id=route-conflict-truncate
224- local config_file=" $WORK_DIR /$changefeed_id .toml"
225- local start_ts
226-
227- echo " [$( date) ] start truncate table keeps source name case"
228- write_route_config " $config_file " " $source_a " " $source_b " " $target_schema "
229- start_ts=$( run_cdc_cli_tso_query " $UP_PD_HOST_1 " " $UP_PD_PORT_1 " )
230- run_sql " CREATE DATABASE $source_a ; CREATE TABLE $source_a .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
231- cdc_cli_changefeed create -c " $changefeed_id " --start-ts=" $start_ts " --sink-uri=" $SINK_URI " --config=" $config_file "
232- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
233-
234- run_sql " TRUNCATE TABLE $source_a .t;" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
235- check_table_exists " $target_schema .t_routed" " $DOWN_TIDB_HOST " " $DOWN_TIDB_PORT " 60
236- run_sql " CREATE DATABASE $source_b ; CREATE TABLE $source_b .t (id INT PRIMARY KEY);" " $UP_TIDB_HOST " " $UP_TIDB_PORT "
237- ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1} :${UP_PD_PORT_1} " $changefeed_id " failed conflict " "
238- cdc_cli_changefeed remove -c " $changefeed_id " || true
239- echo " [$( date) ] finish truncate table keeps source name case"
240- }
241-
242118function run() {
243119 if [ " $SINK_TYPE " != " mysql" ]; then
244120 echo " table_route_conflict_detection only supports mysql sink"
@@ -252,12 +128,7 @@ function run() {
252128
253129 run_static_conflict_case
254130 run_create_table_conflict_case
255- run_rename_table_conflict_case
256131 run_multi_rename_table_conflict_case
257- run_drop_table_release_case
258- run_drop_database_release_case
259- run_rename_table_out_of_filter_release_case
260- run_truncate_table_keeps_source_name_case
261132
262133 cleanup_process " $CDC_BINARY "
263134}
0 commit comments