Merge pull request #67029 from ClickHouse/revert-66993-revert-66785-fix_992

Revert "Revert "Fix for 992 and friends""
This commit is contained in:
Alexander Tokmakov 2024-07-25 13:04:41 +00:00 committed by GitHub
commit cccb710f7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -3940,7 +3940,7 @@ void StorageReplicatedMergeTree::mergeSelectingTask()
merge_selecting_task->schedule(); merge_selecting_task->schedule();
else else
{ {
LOG_TRACE(log, "Scheduling next merge selecting task after {}ms", merge_selecting_sleep_ms); LOG_TRACE(log, "Scheduling next merge selecting task after {}ms, current attempt status: {}", merge_selecting_sleep_ms, result);
merge_selecting_task->scheduleAfter(merge_selecting_sleep_ms); merge_selecting_task->scheduleAfter(merge_selecting_sleep_ms);
} }
} }

View File

@ -41,7 +41,7 @@ function thread3()
function thread4() function thread4()
{ {
while true; do $CLICKHOUSE_CLIENT --receive_timeout=3 -q "OPTIMIZE TABLE alter_table0 FINAL" | grep -Fv "Timeout exceeded while receiving data from server"; done while true; do $CLICKHOUSE_CLIENT --receive_timeout=1 -q "OPTIMIZE TABLE alter_table0 FINAL" | grep -Fv "Timeout exceeded while receiving data from server"; done
} }
function thread5() function thread5()

View File

@ -51,6 +51,14 @@ function check_replication_consistency()
table_name_prefix=$1 table_name_prefix=$1
check_query_part=$2 check_query_part=$2
# Try to kill some mutations because sometimes tests run too much (it's not guarenteed to kill all mutations, see below)
# Try multiple replicas, because queries are not finished yet, and "global" KILL MUTATION may fail due to another query (like DROP TABLE)
readarray -t tables_arr < <(${CLICKHOUSE_CLIENT} -q "SELECT name FROM system.tables WHERE database=currentDatabase() AND name like '$table_name_prefix%'")
for t in "${tables_arr[@]}"
do
${CLICKHOUSE_CLIENT} -q "KILL MUTATION WHERE database=currentDatabase() AND table='$t'" > /dev/null 2>/dev/null ||:
done
# Wait for all queries to finish (query may still be running if thread is killed by timeout) # Wait for all queries to finish (query may still be running if thread is killed by timeout)
num_tries=0 num_tries=0
while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%'") -ne 1 ]]; do while [[ $($CLICKHOUSE_CLIENT -q "SELECT count() FROM system.processes WHERE current_database=currentDatabase() AND query LIKE '%$table_name_prefix%'") -ne 1 ]]; do
@ -96,7 +104,7 @@ function check_replication_consistency()
some_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")
$CLICKHOUSE_CLIENT -q "SYSTEM SYNC REPLICA $some_table PULL" 1>/dev/null 2>/dev/null ||: $CLICKHOUSE_CLIENT -q "SYSTEM SYNC REPLICA $some_table PULL" 1>/dev/null 2>/dev/null ||:
# Forcefully cancel mutations to avoid waiting for them to finish # Forcefully cancel mutations to avoid waiting for them to finish. Kills the remaining mutations
${CLICKHOUSE_CLIENT} -q "KILL MUTATION WHERE database=currentDatabase() AND table like '$table_name_prefix%'" > /dev/null ${CLICKHOUSE_CLIENT} -q "KILL MUTATION WHERE database=currentDatabase() AND table like '$table_name_prefix%'" > /dev/null
# SYNC REPLICA is not enough if some MUTATE_PARTs are not assigned yet # SYNC REPLICA is not enough if some MUTATE_PARTs are not assigned yet