mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #11691 from ClickHouse/fix-race-condition-system-sync-replicas
Fix race condition in SYSTEM SYNC REPLICA
This commit is contained in:
commit
0cb14c836c
@ -646,7 +646,7 @@ void ReplicatedMergeTreeQueue::updateMutations(zkutil::ZooKeeperPtr zookeeper, C
|
||||
}
|
||||
}
|
||||
|
||||
if (some_active_mutations_were_killed)
|
||||
if (some_active_mutations_were_killed && storage.queue_task_handle)
|
||||
storage.queue_task_handle->signalReadyToRun();
|
||||
|
||||
if (!entries_to_load.empty())
|
||||
@ -759,7 +759,7 @@ ReplicatedMergeTreeMutationEntryPtr ReplicatedMergeTreeQueue::removeMutation(
|
||||
LOG_DEBUG(log, "Removed mutation {} from local state.", entry->znode_name);
|
||||
}
|
||||
|
||||
if (mutation_was_active)
|
||||
if (mutation_was_active && storage.queue_task_handle)
|
||||
storage.queue_task_handle->signalReadyToRun();
|
||||
|
||||
return entry;
|
||||
|
@ -5660,9 +5660,16 @@ bool StorageReplicatedMergeTree::waitForShrinkingQueueSize(size_t queue_size, UI
|
||||
|
||||
/// Let's fetch new log entries firstly
|
||||
queue.pullLogsToQueue(getZooKeeper());
|
||||
/// This is significant, because the execution of this task could be delayed at BackgroundPool.
|
||||
/// And we force it to be executed.
|
||||
queue_task_handle->signalReadyToRun();
|
||||
|
||||
{
|
||||
auto lock = queue.lockQueue();
|
||||
if (!queue_task_handle)
|
||||
return false;
|
||||
|
||||
/// This is significant, because the execution of this task could be delayed at BackgroundPool.
|
||||
/// And we force it to be executed.
|
||||
queue_task_handle->signalReadyToRun();
|
||||
}
|
||||
|
||||
Poco::Event target_size_event;
|
||||
auto callback = [&target_size_event, queue_size] (size_t new_queue_size)
|
||||
|
28
tests/queries/0_stateless/01320_create_sync_race_condition.sh
Executable file
28
tests/queries/0_stateless/01320_create_sync_race_condition.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
set -e
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS r;"
|
||||
|
||||
function thread1()
|
||||
{
|
||||
while true; do $CLICKHOUSE_CLIENT -n --query "CREATE TABLE r (x UInt64) ENGINE = ReplicatedMergeTree('/test/table', 'r') ORDER BY x; DROP TABLE r;"; done
|
||||
}
|
||||
|
||||
function thread2()
|
||||
{
|
||||
while true; do $CLICKHOUSE_CLIENT --query "SYSTEM SYNC REPLICA r" 2>/dev/null; done
|
||||
}
|
||||
|
||||
export -f thread1
|
||||
export -f thread2
|
||||
|
||||
timeout 10 bash -c thread1 &
|
||||
timeout 10 bash -c thread2 &
|
||||
|
||||
wait
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS r;"
|
Loading…
Reference in New Issue
Block a user