From a3cba8e06f5fc5f5920f35b72f0f53459a20ce88 Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Wed, 27 Dec 2023 20:27:15 +0100 Subject: [PATCH] Update StorageReplicatedMergeTree.cpp --- src/Storages/StorageReplicatedMergeTree.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 0089eeada00..f143a2ec78b 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -1835,9 +1835,13 @@ MergeTreeData::DataPartsVector StorageReplicatedMergeTree::checkPartChecksumsAnd return {}; } + size_t retries_count = 0; + constexpr size_t MAX_RETRIES_ON_SHUTDOWN = 3; while (true) { - if (shutdown_called || partial_shutdown_called) + /// It still makes sense to make a few attempts on shutdown because we already did some job to create a part + /// and also we want to reduce the probability of issues with unexpected parts on restart + if (++retries_count > MAX_RETRIES_ON_SHUTDOWN && (shutdown_called || partial_shutdown_called)) throw Exception(ErrorCodes::ABORTED, "Cannot commit part because shutdown called"); Coordination::Requests ops;