-
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.
sink(cdc): fix the bug that mq sink can lost callbacks (#9852)
close #9855
- Loading branch information
Showing
4 changed files
with
99 additions
and
4 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
29 changes: 29 additions & 0 deletions
29
tests/integration_tests/mq_sink_lost_callback/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/mq_sink_lost_callback/sync_diff/output" | ||
|
||
source-instances = ["mysql1"] | ||
|
||
target-instance = "tidb0" | ||
|
||
target-check-tables = ["mq_sink_lost_callback.t"] | ||
|
||
[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,57 @@ | ||
#!/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 | ||
|
||
CDC_COUNT=3 | ||
DB_COUNT=4 | ||
|
||
function test_mq_sink_lost_callback() { | ||
rm -rf $WORK_DIR && mkdir -p $WORK_DIR | ||
|
||
start_tidb_cluster --workdir $WORK_DIR | ||
|
||
run_sql "DROP DATABASE if exists mq_sink_lost_callback;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "CREATE DATABASE mq_sink_lost_callback;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "CREATE TABLE mq_sink_lost_callback.t (a int not null primary key);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
|
||
cd $WORK_DIR | ||
export GO_FAILPOINTS='github.com/pingcap/tiflow/cdc/sink/dmlsink/mq/MQSinkGetPartitionError=2*return(true)' | ||
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --loglevel "info" | ||
|
||
TOPIC_NAME="ticdc-kafka-message-test-$RANDOM" | ||
SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=open-protocol&partition-num=4&kafka-version=${KAFKA_VERSION}&max-message-bytes=12582912" | ||
run_cdc_cli changefeed create --sink-uri="$SINK_URI" | ||
|
||
run_sql "INSERT INTO mq_sink_lost_callback.t (a) values (1);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "INSERT INTO mq_sink_lost_callback.t (a) values (2);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "INSERT INTO mq_sink_lost_callback.t (a) values (3);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "INSERT INTO mq_sink_lost_callback.t (a) values (4);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
run_sql "INSERT INTO mq_sink_lost_callback.t (a) values (5);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} | ||
|
||
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}" | ||
fi | ||
check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml | ||
|
||
cleanup_process $CDC_BINARY | ||
stop_tidb_cluster | ||
} | ||
|
||
function run() { | ||
# test kafka sink only in this case | ||
if [ "$SINK_TYPE" != "kafka" ]; then | ||
return | ||
fi | ||
|
||
test_mq_sink_lost_callback $* | ||
} | ||
|
||
trap stop_tidb_cluster EXIT | ||
check_logs $WORK_DIR | ||
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>" |
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