Correctly accuire lock

This commit is contained in:
alesapin 2020-02-09 11:42:15 +03:00
parent 5a96eaf0e8
commit 2dca542d2e

View File

@ -3272,9 +3272,8 @@ void StorageReplicatedMergeTree::alter(
std::vector<ChangedNode> 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);