MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / looksLikeReplicatedDatabasePath

Method looksLikeReplicatedDatabasePath

src/Databases/DatabaseReplicated.cpp:762–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

760}
761
762bool DatabaseReplicated::looksLikeReplicatedDatabasePath(const ZooKeeperPtr & current_zookeeper, const String & path)
763{
764 Coordination::Stat stat;
765 String maybe_database_mark;
766 if (!current_zookeeper->tryGet(path, maybe_database_mark, &stat))
767 return false;
768 if (maybe_database_mark.starts_with(REPLICATED_DATABASE_MARK))
769 return true;
770 if (!maybe_database_mark.empty())
771 return false;
772
773 /// Old versions did not have REPLICATED_DATABASE_MARK. Check specific nodes exist and add mark.
774 Coordination::Requests ops;
775 ops.emplace_back(zkutil::makeCheckRequest(path + "/log", -1));
776 ops.emplace_back(zkutil::makeCheckRequest(path + "/replicas", -1));
777 ops.emplace_back(zkutil::makeCheckRequest(path + "/counter", -1));
778 ops.emplace_back(zkutil::makeCheckRequest(path + "/metadata", -1));
779 ops.emplace_back(zkutil::makeCheckRequest(path + "/max_log_ptr", -1));
780 ops.emplace_back(zkutil::makeCheckRequest(path + "/logs_to_keep", -1));
781 ops.emplace_back(zkutil::makeSetRequest(path, REPLICATED_DATABASE_MARK, stat.version));
782 Coordination::Responses responses;
783 auto res = current_zookeeper->tryMulti(ops, responses);
784 if (res == Coordination::Error::ZOK)
785 return true;
786
787 /// Recheck database mark (just in case of concurrent update).
788 if (!current_zookeeper->tryGet(path, maybe_database_mark, &stat))
789 return false;
790
791 return maybe_database_mark.starts_with(REPLICATED_DATABASE_MARK);
792}
793
794void DatabaseReplicated::createEmptyLogEntry(const ZooKeeperPtr & current_zookeeper)
795{

Callers

nothing calls this directly

Calls 6

makeCheckRequestFunction · 0.85
makeSetRequestFunction · 0.85
tryGetMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
tryMultiMethod · 0.45

Tested by

no test coverage detected