diff --git a/tests/queries/0_stateless/02503_insert_storage_snapshot.reference b/tests/queries/0_stateless/02503_insert_storage_snapshot.reference index 4e07416f18a..9f9dfd29dc6 100644 --- a/tests/queries/0_stateless/02503_insert_storage_snapshot.reference +++ b/tests/queries/0_stateless/02503_insert_storage_snapshot.reference @@ -1 +1 @@ -all_1_1_0 1 1 +"all_1_1_0",1,1 diff --git a/tests/queries/0_stateless/02503_insert_storage_snapshot.sh b/tests/queries/0_stateless/02503_insert_storage_snapshot.sh index af2952839df..b494adeb785 100755 --- a/tests/queries/0_stateless/02503_insert_storage_snapshot.sh +++ b/tests/queries/0_stateless/02503_insert_storage_snapshot.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# Tags: no-parallel set -e @@ -13,7 +14,21 @@ $CLICKHOUSE_CLIENT -q "INSERT INTO t_insert_storage_snapshot VALUES (1)" query_id="$CLICKHOUSE_DATABASE-$RANDOM" $CLICKHOUSE_CLIENT --query_id $query_id -q "INSERT INTO t_insert_storage_snapshot SELECT sleep(1) FROM numbers(1000) SETTINGS max_block_size = 1" 2>/dev/null & -$CLICKHOUSE_CLIENT -q "SELECT name, active, refcount FROM system.parts WHERE database = '$CLICKHOUSE_DATABASE' AND table = 't_insert_storage_snapshot'" +counter=0 retries=60 + +# There can be different background processes which can hold the references to parts +# for a short period of time. To avoid flakyness we check that refcount became 1 at least once during long INSERT query. +# It proves that the INSERT query doesn't hold redundant references to parts. +while [[ $counter -lt $retries ]]; do + query_result=$($CLICKHOUSE_CLIENT -q "SELECT name, active, refcount FROM system.parts WHERE database = '$CLICKHOUSE_DATABASE' AND table = 't_insert_storage_snapshot' FORMAT CSV") + if [ "$query_result" == '"all_1_1_0",1,1' ]; then + echo "$query_result" + break; + fi + sleep 0.1 + ((++counter)) +done + $CLICKHOUSE_CLIENT -q "KILL QUERY WHERE query_id = '$query_id' SYNC" >/dev/null wait