Fix flaky test

This commit is contained in:
Alexey Milovidov 2021-07-20 00:58:48 +03:00
parent 084554aac4
commit 909a50e648
2 changed files with 26 additions and 4 deletions

View File

@ -353,6 +353,9 @@ Chunk DDLQueryStatusSource::generate()
IProcessor::Status DDLQueryStatusSource::prepare()
{
/// This method is overloaded to throw exception after all data is read.
/// Exception is pushed into pipe (instead of simply being thrown) to ensure the order of data processing and exception.
if (finished)
{
bool throw_if_error_on_host = context->getSettingsRef().distributed_ddl_output_mode != DistributedDDLOutputMode::NEVER_THROW;

View File

@ -7,6 +7,25 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
# We execute a distributed DDL query with timeout 1 to check that one host is unavailable and will time out and other complete successfully.
# But sometimes one second is not enough even for healthy host to succeed. Repeat the test in this case.
function run_until_out_contains()
{
PATTERN=$1
shift
while true
do
"$@" > "${CLICKHOUSE_TMP}/out" 2>&1
if grep -q "$PATTERN" "${CLICKHOUSE_TMP}/out"
then
cat "${CLICKHOUSE_TMP}/out"
break;
fi
done
}
$CLICKHOUSE_CLIENT -q "drop table if exists none;"
$CLICKHOUSE_CLIENT -q "drop table if exists throw;"
$CLICKHOUSE_CLIENT -q "drop table if exists null_status;"
@ -18,22 +37,22 @@ $CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_m
# Table exists
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=none -q "create table none on cluster test_shard_localhost (n int) engine=Memory;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//"
# Timeout
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=none -q "drop table none on cluster test_unavailable_shard;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//" | sed "s/Watching task .* is executing longer/Watching task <task> is executing longer/"
run_until_out_contains 'There are 1 unfinished hosts' $CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=none -q "drop table none on cluster test_unavailable_shard;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//" | sed "s/Watching task .* is executing longer/Watching task <task> is executing longer/"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=throw -q "select value from system.settings where name='distributed_ddl_output_mode';"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=throw -q "create table throw on cluster test_shard_localhost (n int) engine=Memory;"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=throw -q "create table throw on cluster test_shard_localhost (n int) engine=Memory format Null;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=throw -q "drop table throw on cluster test_unavailable_shard;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//" | sed "s/Watching task .* is executing longer/Watching task <task> is executing longer/"
run_until_out_contains 'There are 1 unfinished hosts' $CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=throw -q "drop table throw on cluster test_unavailable_shard;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//" | sed "s/Watching task .* is executing longer/Watching task <task> is executing longer/"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=null_status_on_timeout -q "select value from system.settings where name='distributed_ddl_output_mode';"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=null_status_on_timeout -q "create table null_status on cluster test_shard_localhost (n int) engine=Memory;"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=null_status_on_timeout -q "create table null_status on cluster test_shard_localhost (n int) engine=Memory format Null;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=null_status_on_timeout -q "drop table null_status on cluster test_unavailable_shard;"
run_until_out_contains '9000 0 ' $CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=null_status_on_timeout -q "drop table null_status on cluster test_unavailable_shard;"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=never_throw -q "select value from system.settings where name='distributed_ddl_output_mode';"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=never_throw -q "create table never_throw on cluster test_shard_localhost (n int) engine=Memory;"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=600 --distributed_ddl_output_mode=never_throw -q "create table never_throw on cluster test_shard_localhost (n int) engine=Memory;" 2>&1 | sed "s/DB::Exception/Error/g" | sed "s/ (version.*)//"
$CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=never_throw -q "drop table never_throw on cluster test_unavailable_shard;"
run_until_out_contains '9000 0 ' $CLICKHOUSE_CLIENT --distributed_ddl_task_timeout=1 --distributed_ddl_output_mode=never_throw -q "drop table never_throw on cluster test_unavailable_shard;"
$CLICKHOUSE_CLIENT -q "drop table if exists none;"
$CLICKHOUSE_CLIENT -q "drop table if exists throw;"