From 2dca542d2e63324c3b3ab7b021a58b530721c416 Mon Sep 17 00:00:00 2001 From: alesapin Date: Sun, 9 Feb 2020 11:42:15 +0300 Subject: [PATCH] Correctly accuire lock --- dbms/src/Storages/StorageReplicatedMergeTree.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 7b9d723e629..774983334b4 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -3272,9 +3272,8 @@ void StorageReplicatedMergeTree::alter( std::vector changed_nodes; { - /// Just to read current structure. Alter will be done in separate thread. - auto table_lock = lockStructureForShare(false, query_context.getCurrentQueryId()); - + /// Guard races of alter thread metadata change + lockNewDataStructureExclusively(table_lock_holder, query_context.getCurrentQueryId()); if (is_readonly) throw Exception("Can't ALTER readonly table", ErrorCodes::TABLE_IS_READ_ONLY);