From d9ebec472b8d491117fc92631b35c42491f63c94 Mon Sep 17 00:00:00 2001 From: alesapin Date: Fri, 14 Feb 2020 12:24:00 +0300 Subject: [PATCH] More simple --- .../ReplicatedMergeTreeBlockOutputStream.cpp | 10 ---------- .../Storages/StorageReplicatedMergeTree.cpp | 19 +------------------ 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.cpp index ce5b5212316..014e9fb417a 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.cpp @@ -256,16 +256,6 @@ void ReplicatedMergeTreeBlockOutputStream::commitPart(zkutil::ZooKeeperPtr & zoo log_entry.toString(), zkutil::CreateMode::PersistentSequential)); - /// We check metadata_version has the same version as shared node. - /// In other case we may have parts, which nobody will alter. - /// - ops.emplace_back(zkutil::makeCheckRequest(storage.zookeeper_path + "/metadata", storage.getMetadataVersion())); - - /// We update version of block_number/partition node to register fact of new insert. - /// If we want to be sure, that no inserts happend in some period of time, than we can receive - /// version of all partition nodes inside block numbers and then make check requirests in zookeeper transaction. - ops.emplace_back(zkutil::makeSetRequest(storage.zookeeper_path + "/block_numbers/" + part->info.partition_id, "", -1)); - /// Deletes the information that the block number is used for writing. block_number_lock->getUnlockOps(ops); diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index bf52618e727..5b33185f37e 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -3363,28 +3363,11 @@ void StorageReplicatedMergeTree::alter( Coordination::Stat mutations_stat; zookeeper->get(mutations_path, &mutations_stat); - Strings partitions = zookeeper->getChildren(zookeeper_path + "/block_numbers"); - - std::vector> partition_futures; - for (const String & partition : partitions) - partition_futures.push_back(zookeeper->asyncGet(zookeeper_path + "/block_numbers/" + partition)); - - std::unordered_map partition_versions; - for (size_t i = 0; i < partition_futures.size(); ++i) - { - auto stat = partition_futures[i].get().stat; - auto partition = partitions[i]; - partition_versions[partition] = stat.version; - } - lock_holder.emplace( zookeeper_path + "/block_numbers", "block-", zookeeper_path + "/temp", *zookeeper); for (const auto & lock : lock_holder->getLocks()) - { mutation_entry.block_numbers[lock.partition_id] = lock.number; - ops.emplace_back(zkutil::makeCheckRequest(zookeeper_path + "/block_numbers/" + lock.partition_id, partition_versions[lock.partition_id])); - } mutation_entry.create_time = time(nullptr); @@ -3449,7 +3432,7 @@ void StorageReplicatedMergeTree::alter( if (!unwaited.empty()) throw Exception("Some replicas doesn't finish metadata alter", ErrorCodes::UNFINISHED); - if (mutation_znode) + if (mutation_znode.has_value() && !mutation_znode->empty()) { LOG_DEBUG(log, "Metadata changes applied. Will wait for data changes."); waitMutation(*mutation_znode, query_context.getSettingsRef().replication_alter_partitions_sync);