You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/queries/0_stateless/mergetree_mutations.lib
+10-15Lines changed: 10 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,16 @@ function wait_for_mutation()
7
7
local database=$3
8
8
database=${database:="${CLICKHOUSE_DATABASE}"}
9
9
10
-
foriin {1..100}
10
+
for_in {1..300}
11
11
do
12
12
sleep 0.1
13
13
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT min(is_done) FROM system.mutations WHERE database='$database' AND table='$table' AND mutation_id='$mutation_id'")-eq 1 ]];then
14
-
break
14
+
return
15
15
fi
16
-
17
-
if [[ $i-eq 100 ]];then
18
-
echo"Timed out while waiting for mutation to execute!"
19
-
fi
20
-
21
16
done
17
+
18
+
echo"Timed out while waiting for mutation to execute!"
19
+
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.mutations WHERE database='$database' AND table like '$table' AND mutation_id='$mutation_id' AND is_done=0"
22
20
}
23
21
24
22
functionwait_for_all_mutations()
@@ -27,19 +25,16 @@ function wait_for_all_mutations()
27
25
local database=$2
28
26
database=${database:="${CLICKHOUSE_DATABASE}"}
29
27
30
-
foriin {1..200}
28
+
for_in {1..600}
31
29
do
32
30
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT coalesce(minOrNull(is_done), 1) FROM system.mutations WHERE database='$database' AND table like '$table'")-eq 1 ]];then
33
-
break
31
+
return
34
32
fi
35
-
36
-
if [[ $i-eq 200 ]];then
37
-
echo"Timed out while waiting for mutation to execute!"
38
-
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.mutations WHERE database='$database' AND table like '$table' AND is_done=0"
39
-
fi
40
-
41
33
sleep 0.3
42
34
done
35
+
36
+
echo"Timed out while waiting for mutation to execute!"
37
+
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.mutations WHERE database='$database' AND table like '$table' AND is_done=0"
"SELECT DISTINCT substr(new_part_name, 1, position(new_part_name, '_') - 1) AS partition_id
12
13
FROM system.replication_queue
@@ -15,8 +16,10 @@ function try_sync_replicas()
15
16
FROM system.parts
16
17
WHERE (database = currentDatabase()) AND (table LIKE '$table_name_prefix%')
17
18
))")
18
-
readarray -t tables_arr <<(${CLICKHOUSE_CLIENT} -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' AND engine like '%Replicated%'")
19
+
local tables_arr
20
+
readarray -t tables_arr <<(${CLICKHOUSE_CLIENT} -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' AND (engine like '%Replicated%' or engine like '%Shared%')")
"select 'sync failed, queue:', * from system.replication_queue where database=currentDatabase() and table='$t' order by database, table, node_name"&&exit 1) &
40
43
pids[${i}]=$!
41
44
i=$((i +1))
42
45
done
46
+
47
+
local pid
43
48
forpidin"${pids[@]}";do
44
49
wait$pid|| (echo "Failed to sync some replicas"&&exit 1)
45
50
done
@@ -48,21 +53,23 @@ function try_sync_replicas()
48
53
49
54
functioncheck_replication_consistency()
50
55
{
51
-
table_name_prefix=$1
52
-
check_query_part=$2
56
+
localtable_name_prefix=$1
57
+
localcheck_query_part=$2
53
58
59
+
local tables_arr
54
60
# Try to kill some mutations because sometimes tests run too much (it's not guarenteed to kill all mutations, see below)
55
61
# Try multiple replicas, because queries are not finished yet, and "global" KILL MUTATION may fail due to another query (like DROP TABLE)
56
62
readarray -t tables_arr <<(${CLICKHOUSE_CLIENT} -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%'")
63
+
local t
57
64
fortin"${tables_arr[@]}"
58
65
do
59
66
${CLICKHOUSE_CLIENT} -q "KILL MUTATION WHERE database=currentDatabase() AND table='$t'"> /dev/null 2>/dev/null ||:
60
67
done
61
68
62
69
# Wait for all queries to finish (query may still be running if a thread is killed by timeout)
63
-
num_tries=0
70
+
localnum_tries=0
64
71
while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%'")-ne 1 ]];do
65
-
sleep 1;
72
+
sleep 1
66
73
num_tries=$((num_tries+1))
67
74
if [ $num_tries-eq 250 ];then
68
75
echo"Queries for $table_name_prefix did not finish automatically after 250+ seconds"
@@ -78,7 +85,7 @@ function check_replication_consistency()
78
85
79
86
# Do not check anything if all replicas are readonly,
80
87
# because is this case all replicas are probably lost (it may happen and it's not a bug)
81
-
res=$($CLICKHOUSE_CLIENT -q "SELECT count() - sum(is_readonly) FROM system.replicas WHERE database=currentDatabase() AND table LIKE '$table_name_prefix%'")
88
+
localres=$($CLICKHOUSE_CLIENT -q "SELECT count() - sum(is_readonly) FROM system.replicas WHERE database=currentDatabase() AND table LIKE '$table_name_prefix%'")
82
89
if [ $res-eq 0 ];then
83
90
# Print dummy lines
84
91
echo"Replication did not hang: synced all replicas of $table_name_prefix"
@@ -96,12 +103,12 @@ function check_replication_consistency()
96
103
break
97
104
fi
98
105
done
99
-
time_left=$((300- num_tries))
106
+
localtime_left=$((300- num_tries))
100
107
101
108
# Trigger pullLogsToQueue(...) and updateMutations(...) on some replica to make it pull all mutations, so it will be possible to kill them
102
-
some_table=$($CLICKHOUSE_CLIENT -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' ORDER BY rand() LIMIT 1")
109
+
localsome_table=$($CLICKHOUSE_CLIENT -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' ORDER BY rand() LIMIT 1")
some_table=$($CLICKHOUSE_CLIENT -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' ORDER BY rand() LIMIT 1")
111
+
localsome_table=$($CLICKHOUSE_CLIENT -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%' ORDER BY rand() LIMIT 1")
Copy file name to clipboardExpand all lines: tests/queries/shell_config.sh
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -160,7 +160,7 @@ function wait_for_queries_to_finish()
160
160
{
161
161
local max_tries="${1:-20}"
162
162
# Wait for all queries to finish (query may still be running if a thread is killed by timeout)
163
-
num_tries=0
163
+
localnum_tries=0
164
164
while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query NOT LIKE '%system.processes%'")-ne 0 ]];do
0 commit comments