ReplicatedMergeTree ALTER update metadata_version in single transaction

This commit is contained in:
Maksim Kita 2024-02-13 19:51:14 +03:00
parent 4fb76a6e25
commit dca627026c

View File

@ -5817,6 +5817,7 @@ bool StorageReplicatedMergeTree::executeMetadataAlter(const StorageReplicatedMer
Coordination::Requests requests;
requests.emplace_back(zkutil::makeSetRequest(fs::path(replica_path) / "columns", entry.columns_str, -1));
requests.emplace_back(zkutil::makeSetRequest(fs::path(replica_path) / "metadata", entry.metadata_str, -1));
requests.emplace_back(zkutil::makeSetRequest(fs::path(replica_path) / "metadata_version", std::to_string(entry.alter_version), -1));
auto table_id = getStorageID();
auto alter_context = getContext();
@ -5863,10 +5864,6 @@ bool StorageReplicatedMergeTree::executeMetadataAlter(const StorageReplicatedMer
resetObjectColumnsFromActiveParts(parts_lock);
}
/// This transaction may not happen, but it's OK, because on the next retry we will eventually create/update this node
/// TODO Maybe do in in one transaction for Replicated database?
zookeeper->createOrUpdate(fs::path(replica_path) / "metadata_version", std::to_string(current_metadata->getMetadataVersion()), zkutil::CreateMode::Persistent);
return true;
}