From b993667156d5fc4e0a9d1a876374a25b042e6a0c Mon Sep 17 00:00:00 2001 From: proller Date: Thu, 12 Oct 2017 23:42:58 +0300 Subject: [PATCH] Try fix strange terminate (#1329) * Tests: External: rename --use_http => --no_http and fix * Try fix strange terminate --- dbms/src/Storages/StorageReplicatedMergeTree.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 355d5fe5e90..59723999643 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -1975,6 +1975,13 @@ void StorageReplicatedMergeTree::becomeLeader() if (shutdown_called) return; + if (merge_selecting_thread.joinable()) + { + LOG_INFO(log, "Deleting old leader"); + is_leader_node = false; // exit trigger inside thread + merge_selecting_thread.join(); + } + LOG_INFO(log, "Became leader"); is_leader_node = true; merge_selecting_thread = std::thread(&StorageReplicatedMergeTree::mergeSelectingThread, this);