Adjusted timings in test + more verbose diagnostics

This commit is contained in:
Alexander Kazakov 2019-09-20 00:20:58 +03:00
parent 90c9d83fa5
commit 2d807368e1
4 changed files with 33 additions and 22 deletions

View File

@ -342,9 +342,12 @@ void InterpreterSystemQuery::syncReplica(ASTSystemQuery & query)
{
LOG_TRACE(log, "Synchronizing entries in replica's queue with table's log and waiting for it to become empty");
if (!storage_replicated->waitForShrinkingQueueSize(0, context.getSettingsRef().receive_timeout.totalMilliseconds()))
{
LOG_ERROR(log, "SYNC REPLICA " + database_name + "." + table_name + ": Timed out!");
throw Exception(
"SYNC REPLICA " + database_name + "." + table_name + ": command timed out! "
"See the 'receive_timeout' setting", ErrorCodes::TIMEOUT_EXCEEDED);
}
LOG_TRACE(log, "SYNC REPLICA " + database_name + "." + table_name + ": OK");
}
else

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
${CLICKHOUSE_CLIENT} -n -q "
CREATE TABLE table_1013_1 (x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/${CLICKHOUSE_DATABASE}.table_1013', 'r1') ORDER BY x;
CREATE TABLE table_1013_2 (x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/${CLICKHOUSE_DATABASE}.table_1013', 'r2') ORDER BY x;
SYSTEM STOP FETCHES table_1013_2;
INSERT INTO table_1013_1 VALUES (1)
"
timeout 2s ${CLICKHOUSE_CLIENT} -n -q "SET receive_timeout=1; SYSTEM SYNC REPLICA table_1013_2" 2>&1 \
| fgrep -q "DB::Exception: SYNC REPLICA ${CLICKHOUSE_DATABASE}.table_1013_2: command timed out!" \
&& echo 'OK' \
|| (${CLICKHOUSE_CLIENT} -q "KILL QUERY WHERE query = 'SYSTEM SYNC REPLICA table_1013_2'"; echo "Failed!")
${CLICKHOUSE_CLIENT} -n -q "
DROP TABLE IF EXISTS table_1013_2;
DROP TABLE IF EXISTS table_1013_1;"

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
R1=table_1013_1
R2=table_1013_2
${CLICKHOUSE_CLIENT} -n -q "
DROP TABLE IF EXISTS $R1;
DROP TABLE IF EXISTS $R2;
CREATE TABLE $R1 (x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/${CLICKHOUSE_DATABASE}.table_1013', 'r1') ORDER BY x;
CREATE TABLE $R2 (x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/${CLICKHOUSE_DATABASE}.table_1013', 'r2') ORDER BY x;
SYSTEM STOP FETCHES $R2;
INSERT INTO $R1 VALUES (1)
"
timeout 10s ${CLICKHOUSE_CLIENT} -n -q "
SET receive_timeout=1;
SYSTEM SYNC REPLICA $R2
" 2>&1 | fgrep -q "DB::Exception: SYNC REPLICA ${CLICKHOUSE_DATABASE}.$R2: command timed out!" && echo 'OK' || echo 'Failed!'
# By dropping tables all related SYNC REPLICA queries would be terminated as well
${CLICKHOUSE_CLIENT} -n -q "
DROP TABLE IF EXISTS $R2;
DROP TABLE IF EXISTS $R1;
"