提交 499b6764 编写于 作者: A Alexey Milovidov

Allow to startup with replicated tables in readonly mode when there is no...

Allow to startup with replicated tables in readonly mode when there is no ZooKeeper configured [#CLICKHOUSE-2]
上级 bd23b879
...@@ -1358,8 +1358,7 @@ zkutil::ZooKeeperPtr Context::getZooKeeper() const ...@@ -1358,8 +1358,7 @@ zkutil::ZooKeeperPtr Context::getZooKeeper() const
bool Context::hasZooKeeper() const bool Context::hasZooKeeper() const
{ {
std::lock_guard<std::mutex> lock(shared->zookeeper_mutex); return getConfigRef().has("zookeeper");
return shared->zookeeper != nullptr;
} }
......
...@@ -304,6 +304,7 @@ public: ...@@ -304,6 +304,7 @@ public:
const MergeList & getMergeList() const; const MergeList & getMergeList() const;
/// If the current session is expired at the time of the call, synchronously creates and returns a new session with the startNewSession() call. /// If the current session is expired at the time of the call, synchronously creates and returns a new session with the startNewSession() call.
/// If no ZooKeeper configured, throws an exception.
std::shared_ptr<zkutil::ZooKeeper> getZooKeeper() const; std::shared_ptr<zkutil::ZooKeeper> getZooKeeper() const;
/// Has ready or expired ZooKeeper /// Has ready or expired ZooKeeper
bool hasZooKeeper() const; bool hasZooKeeper() const;
......
...@@ -191,7 +191,7 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( ...@@ -191,7 +191,7 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
const MergeTreeSettings & settings_, const MergeTreeSettings & settings_,
bool has_force_restore_data_flag) bool has_force_restore_data_flag)
: context(context_), : context(context_),
current_zookeeper(context.getZooKeeper()), database_name(database_name_), database_name(database_name_),
table_name(name_), full_path(path_ + escapeForFileName(table_name) + '/'), table_name(name_), full_path(path_ + escapeForFileName(table_name) + '/'),
zookeeper_path(context.getMacros()->expand(zookeeper_path_)), zookeeper_path(context.getMacros()->expand(zookeeper_path_)),
replica_name(context.getMacros()->expand(replica_name_)), replica_name(context.getMacros()->expand(replica_name_)),
...@@ -216,6 +216,9 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( ...@@ -216,6 +216,9 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
zookeeper_path = "/" + zookeeper_path; zookeeper_path = "/" + zookeeper_path;
replica_path = zookeeper_path + "/replicas/" + replica_name; replica_path = zookeeper_path + "/replicas/" + replica_name;
if (context.hasZooKeeper())
current_zookeeper = context.getZooKeeper();
bool skip_sanity_checks = false; bool skip_sanity_checks = false;
if (current_zookeeper && current_zookeeper->exists(replica_path + "/flags/force_restore_data")) if (current_zookeeper && current_zookeeper->exists(replica_path + "/flags/force_restore_data"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册