Skip to content

Commit c2b2533

Browse files
Merge pull request #58748 from ClickHouse/imp-01600_parts
Return and fix 01600_parts_states_metrics_long test
2 parents fa062e7 + 4d45d0b commit c2b2533

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1
2+
1
3+
1
4+
1
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
# shellcheck source=../shell_config.sh
5+
. "$CURDIR"/../shell_config.sh
6+
7+
# NOTE: database = $CLICKHOUSE_DATABASE is unwanted
8+
verify_sql="SELECT
9+
(SELECT sumIf(value, metric = 'PartsActive'), sumIf(value, metric = 'PartsOutdated') FROM system.metrics)
10+
= (SELECT sum(active), sum(NOT active) FROM
11+
(SELECT active FROM system.parts UNION ALL SELECT active FROM system.projection_parts UNION ALL SELECT 1 FROM system.dropped_tables_parts))"
12+
13+
# The query is not atomic - it can compare states between system.parts and system.metrics from different points in time.
14+
# So, there is inherent race condition. But it should get expected result eventually.
15+
# In case of test failure, this code will do infinite loop and timeout.
16+
verify()
17+
{
18+
while true
19+
do
20+
result=$( $CLICKHOUSE_CLIENT -m --query="$verify_sql" )
21+
[ "$result" = "1" ] && break
22+
sleep 0.1
23+
done
24+
echo 1
25+
}
26+
27+
$CLICKHOUSE_CLIENT --database_atomic_wait_for_drop_and_detach_synchronously=1 --query="DROP TABLE IF EXISTS test_table"
28+
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_table(data Date) ENGINE = MergeTree PARTITION BY toYear(data) ORDER BY data;"
29+
30+
$CLICKHOUSE_CLIENT --query="INSERT INTO test_table VALUES ('1992-01-01')"
31+
verify
32+
33+
$CLICKHOUSE_CLIENT --query="INSERT INTO test_table VALUES ('1992-01-02')"
34+
verify
35+
36+
$CLICKHOUSE_CLIENT --query="OPTIMIZE TABLE test_table FINAL"
37+
verify
38+
39+
$CLICKHOUSE_CLIENT --database_atomic_wait_for_drop_and_detach_synchronously=1 --query="DROP TABLE test_table"
40+
verify

0 commit comments

Comments
 (0)