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
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ function wait_for_mutation()
7
7
local database=$3
8
8
database=${database:="${CLICKHOUSE_DATABASE}"}
9
9
10
+
local i
10
11
foriin {1..100}
11
12
do
12
13
sleep 0.1
@@ -27,6 +28,7 @@ function wait_for_all_mutations()
27
28
local database=$2
28
29
database=${database:="${CLICKHOUSE_DATABASE}"}
29
30
31
+
local i
30
32
foriin {1..200}
31
33
do
32
34
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT coalesce(minOrNull(is_done), 1) FROM system.mutations WHERE database='$database' AND table like '$table'")-eq 1 ]];then
"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
))")
19
+
local tables_arr
18
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%'")
"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")
0 commit comments