Skip to content

Commit 6850041

Browse files
authored
Merge pull request ClickHouse#79213 from ClickHouse/fix_flaky_02908_many_requests_to_system_replicas
Fix flaky 02908_many_requests_to_system_replicas
2 parents a480434 + 70122b3 commit 6850041

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tests/queries/0_stateless/02908_many_requests_to_system_replicas.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ echo "Making $CONCURRENCY requests to system.replicas"
5656

5757
for i in $(seq 1 $CONCURRENCY)
5858
do
59-
curl "$CLICKHOUSE_URL" --silent --fail --show-error --data "SELECT * FROM system.replicas WHERE database=currentDatabase() FORMAT Null SETTINGS log_comment='02908_many_requests';" &>/dev/null &
59+
curl "$CLICKHOUSE_URL" --silent --fail --show-error --data "
60+
SELECT * FROM system.replicas WHERE database=currentDatabase() FORMAT Null SETTINGS log_comment='02908_many_requests';" &>/dev/null &
6061
done
6162

6263
echo "Query system.replicas while waiting for other concurrent requests to finish"
@@ -67,11 +68,25 @@ curl "$CLICKHOUSE_URL" --silent --fail --show-error --data "SELECT sum(is_leader
6768

6869
wait;
6970

71+
72+
# Make a request to system.replicas without other concurrent requests to figure out the baseline of how many ZK requests it makes
73+
curl "$CLICKHOUSE_URL" --silent --fail --show-error --data "
74+
SELECT * FROM system.replicas WHERE database=currentDatabase() FORMAT Null SETTINGS log_comment='02908_many_requests-baseline';" &>/dev/null
75+
76+
7077
$CLICKHOUSE_CLIENT -q "
7178
SYSTEM FLUSH LOGS query_log;
7279
73-
-- Check that number of ZK request is less then a half of (total replicas * concurrency)
74-
SELECT sum(ProfileEvents['ZooKeeperTransactions']) < (${NUM_TABLES} * 3 * ${CONCURRENCY} / 2)
75-
FROM system.query_log
76-
WHERE current_database=currentDatabase() AND log_comment='02908_many_requests';
80+
-- Check that average number of ZK request is less then a half of max requests
81+
WITH
82+
(SELECT ProfileEvents['ZooKeeperTransactions']
83+
FROM system.query_log
84+
WHERE current_database=currentDatabase() AND log_comment='02908_many_requests-baseline' AND type = 'QueryFinish') AS max_zookeeper_requests
85+
SELECT
86+
if (sum(ProfileEvents['ZooKeeperTransactions']) <= (max_zookeeper_requests * ${CONCURRENCY} / 2) as passed,
87+
passed::String,
88+
'More ZK requests then expected: max_zookeeper_requests=' || max_zookeeper_requests::String || ' total_zk_requests=' || sum(ProfileEvents['ZooKeeperTransactions'])::String
89+
)
90+
FROM system.query_log
91+
WHERE current_database=currentDatabase() AND log_comment='02908_many_requests' AND type = 'QueryFinish';
7792
"

0 commit comments

Comments
 (0)