Finalize mutations in background (#10526)

This commit is contained in:
alesapin 2020-04-27 19:19:04 +03:00 committed by GitHub
parent f34a6dc482
commit 228dbf475e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,6 +129,7 @@ namespace ActionLocks
static const auto QUEUE_UPDATE_ERROR_SLEEP_MS = 1 * 1000; static const auto QUEUE_UPDATE_ERROR_SLEEP_MS = 1 * 1000;
static const auto MERGE_SELECTING_SLEEP_MS = 5 * 1000; static const auto MERGE_SELECTING_SLEEP_MS = 5 * 1000;
static const auto MUTATIONS_FINALIZING_SLEEP_MS = 1 * 1000; static const auto MUTATIONS_FINALIZING_SLEEP_MS = 1 * 1000;
static const auto MUTATIONS_FINALIZING_IDLE_SLEEP_MS = 5 * 1000;
void StorageReplicatedMergeTree::setZooKeeper(zkutil::ZooKeeperPtr zookeeper) void StorageReplicatedMergeTree::setZooKeeper(zkutil::ZooKeeperPtr zookeeper)
@ -2284,8 +2285,19 @@ void StorageReplicatedMergeTree::mutationsFinalizingTask()
} }
if (needs_reschedule) if (needs_reschedule)
{
mutations_finalizing_task->scheduleAfter(MUTATIONS_FINALIZING_SLEEP_MS); mutations_finalizing_task->scheduleAfter(MUTATIONS_FINALIZING_SLEEP_MS);
} }
else
{
/// Even if no mutations seems to be done or appeared we are trying to
/// finalize them in background because manual control the launch of
/// this function is error prone. This can lead to mutations that
/// processed all the parts but have is_done=0 state for a long time. Or
/// killed mutations, which are also considered as undone.
mutations_finalizing_task->scheduleAfter(MUTATIONS_FINALIZING_IDLE_SLEEP_MS);
}
}
bool StorageReplicatedMergeTree::createLogEntryToMergeParts( bool StorageReplicatedMergeTree::createLogEntryToMergeParts(