@@ -66,8 +66,18 @@ function wait_checkpoint_advanced() {
6666export -f checkpoint_ts
6767export -f check_ts_forward
6868
69+ function check_sentinel_rows() {
70+ local t3_cnt=$1
71+ local t4_cnt=$2
72+ run_sql " select count(*) as cnt from ddl_reentrant.t3 where a = 1 and b = 100" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
73+ check_contains " cnt: ${t3_cnt} "
74+ run_sql " select count(*) as cnt from ddl_reentrant.t4 where a = 1 and b = 100" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
75+ check_contains " cnt: ${t4_cnt} "
76+ }
77+
6978function ddl_test() {
70- ddl=$1
79+ local ddl=$1
80+ shift
7181
7282 echo " ------------------------------------------"
7383 echo " test ddl $ddl "
@@ -82,6 +92,9 @@ function ddl_test() {
8292 run_sql " $ddl " ${UP_TIDB_HOST} ${UP_TIDB_PORT}
8393 tso_after=$( run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1} )
8494 wait_checkpoint_advanced " $changefeedid " " $tso_after "
95+ if [[ $# -gt 0 ]]; then
96+ " $@ "
97+ fi
8598
8699 cdc_cli_changefeed pause --changefeed-id=${changefeedid}
87100 cdc_cli_changefeed resume --no-confirm --changefeed-id=${changefeedid} --overwrite-checkpoint-ts=${checkpoint_before}
@@ -121,15 +134,13 @@ function run() {
121134 run_sql " insert into ddl_reentrant.t3 values (1, 100)" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
122135 seed_tso=$( run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1} )
123136 wait_checkpoint_advanced " $changefeedid " " $seed_tso "
137+ check_sentinel_rows 1 0
124138
125- ddl_test " alter table ddl_reentrant.t3 exchange partition p0 with table ddl_reentrant.t4 without validation"
139+ ddl_test " alter table ddl_reentrant.t3 exchange partition p0 with table ddl_reentrant.t4 without validation" check_sentinel_rows 0 1
126140
127- # If replay re-executed exchange partition instead of skipping it via ddl_ts_table,
128- # the sentinel row would be swapped back into t3.
129- run_sql " select count(*) as cnt from ddl_reentrant.t3 where a = 1 and b = 100" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
130- check_contains " cnt: 0"
131- run_sql " select count(*) as cnt from ddl_reentrant.t4 where a = 1 and b = 100" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
132- check_contains " cnt: 1"
141+ # resume --overwrite-checkpoint-ts clears ddl_ts_v1 for the changefeed and
142+ # re-executes exchange partition, swapping the sentinel row back into t3.
143+ check_sentinel_rows 1 0
133144
134145 cleanup_process $CDC_BINARY
135146}
0 commit comments