Skip to content

Commit 5aedbac

Browse files
committed
Fix 01246_buffer_flush flakiness
- reduce min_time for Buffer's min test - rewrite the test to .sh to avoid extra sleeping time (with .sql we have to wait the max time) - change the assertion for min test, the time there should not exceed max time (100 seconds), this should fix with test flakiness [1] even after [2]. [1]: https://s3.amazonaws.com/clickhouse-test-reports/0/76119a4567ce2ac9c0aff715c1a9ba2607e806e0/stateless_tests__tsan__[3_5].html [2]: #65310 Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
1 parent 77e7850 commit 5aedbac

2 files changed

Lines changed: 76 additions & 50 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
# Tags: no-fasttest
3+
4+
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5+
# shellcheck source=../shell_config.sh
6+
. "$CUR_DIR"/../shell_config.sh
7+
8+
function elapsed_sec()
9+
{
10+
local expr=$1 && shift
11+
local start end
12+
start=$(date +%s.%N)
13+
while ! eval "$expr"; do
14+
sleep 0.5
15+
done
16+
end=$(date +%s.%N)
17+
$CLICKHOUSE_LOCAL -q "select floor($end-$start)"
18+
}
19+
20+
$CLICKHOUSE_CLIENT -nm -q "
21+
drop table if exists data_01256;
22+
drop table if exists buffer_01256;
23+
24+
create table data_01256 as system.numbers Engine=Memory();
25+
"
26+
27+
echo "min"
28+
$CLICKHOUSE_CLIENT -nm -q "
29+
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
30+
2, 100, /* time */
31+
4, 100, /* rows */
32+
1, 1e6 /* bytes */
33+
);
34+
insert into buffer_01256 select * from system.numbers limit 5;
35+
select count() from data_01256;
36+
"
37+
sec=$(elapsed_sec '[[ $($CLICKHOUSE_CLIENT -q "select count() from data_01256") -eq 5 ]]')
38+
[[ $sec -ge 2 ]] || echo "Buffer flushed too early, min_time=2, flushed after $sec sec"
39+
[[ $sec -lt 100 ]] || echo "Buffer flushed too late, max_time=100, flushed after $sec sec"
40+
$CLICKHOUSE_CLIENT -q "select count() from data_01256"
41+
$CLICKHOUSE_CLIENT -q "drop table buffer_01256"
42+
43+
echo "max"
44+
$CLICKHOUSE_CLIENT -nm -q "
45+
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
46+
100, 2, /* time */
47+
0, 100, /* rows */
48+
0, 1e6 /* bytes */
49+
);
50+
insert into buffer_01256 select * from system.numbers limit 5;
51+
select count() from data_01256;
52+
"
53+
sec=$(elapsed_sec '[[ $($CLICKHOUSE_CLIENT -q "select count() from data_01256") -eq 10 ]]')
54+
[[ $sec -ge 2 ]] || echo "Buffer flushed too early, max_time=2, flushed after $sec sec"
55+
$CLICKHOUSE_CLIENT -q "select count() from data_01256"
56+
$CLICKHOUSE_CLIENT -q "drop table buffer_01256"
57+
58+
echo "direct"
59+
$CLICKHOUSE_CLIENT -nm -q "
60+
create table buffer_01256 as system.numbers Engine=Buffer(currentDatabase(), data_01256, 1,
61+
100, 100, /* time */
62+
0, 9, /* rows */
63+
0, 1e6 /* bytes */
64+
);
65+
insert into buffer_01256 select * from system.numbers limit 10;
66+
select count() from data_01256;
67+
"
68+
69+
echo "drop"
70+
$CLICKHOUSE_CLIENT -nm -q "
71+
insert into buffer_01256 select * from system.numbers limit 10;
72+
drop table if exists buffer_01256;
73+
select count() from data_01256;
74+
"
75+
76+
$CLICKHOUSE_CLIENT -q "drop table data_01256"

tests/queries/0_stateless/01246_buffer_flush.sql

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)