ClickHouse/tests/queries/0_stateless/02703_max_local_write_bandwidth.sh
Azat Khuzhin b608490885 Fix 02703_max_local_write_bandwidth flakiness
LocalWriteThrottlerSleepMicroseconds is too unpredictable in debug
builds, event with 50% of allowed error it still fails [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/51006/6cc4f76707b196b0f02938671f62c9bb3d267faa/stateless_tests__debug__%5B2_5%5D.html

Looking into query_log artifacts:

    $ clickhouse-local --file query_log.tsv.zst --input-format TSVWithNamesAndTypes -q "select query_duration_ms, ProfileEvents['LocalWriteThrottlerSleepMicroseconds'] from table where log_comment = '02703_max_local_write_bandwidth.sh' and type != 'QueryStart' and query_id = 'eebxgbfqyt'" --output-format Vertical
    Row 1:
    ──────
    query_duration_ms:                                                   15'608
    arrayElement(ProfileEvents, 'LocalWriteThrottlerSleepMicroseconds'): 1'385'203

So query duration is 15.6sec, while throttle sleeps only 1.39sec, which
is only 9%, apparently it waits somewhere else.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-06-17 13:56:29 +02:00

26 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tags: no-s3-storage
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -nm -q "
drop table if exists data;
create table data (key UInt64 CODEC(NONE)) engine=MergeTree() order by tuple() settings min_bytes_for_wide_part=1e9;
"
query_id=$(random_str 10)
# writes 1e6*8 bytes with 1M bandwith it should take (8-1)/1=7 seconds
$CLICKHOUSE_CLIENT --query_id "$query_id" -q "insert into data select * from numbers(1e6) settings max_local_write_bandwidth='1M'"
$CLICKHOUSE_CLIENT -nm -q "
SYSTEM FLUSH LOGS;
SELECT
query_duration_ms >= 7e3,
ProfileEvents['WriteBufferFromFileDescriptorWriteBytes'] > 8e6,
ProfileEvents['LocalWriteThrottlerBytes'] > 8e6
/* LocalWriteThrottlerSleepMicroseconds is too unreliable in debug build, but query_duration_ms is enough */
FROM system.query_log
WHERE current_database = '$CLICKHOUSE_DATABASE' AND query_id = '$query_id' AND type != 'QueryStart'
"