diff --git a/src/rdsn/src/zookeeper/zookeeper_session.cpp b/src/rdsn/src/zookeeper/zookeeper_session.cpp index 4c9bb5b9fa..bd0bfafc29 100644 --- a/src/rdsn/src/zookeeper/zookeeper_session.cpp +++ b/src/rdsn/src/zookeeper/zookeeper_session.cpp @@ -176,6 +176,9 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb) } dassert(_handle != nullptr, "zookeeper session init failed"); } + int ret = zoo_set_servers_resolution_delay( + _handle, zookeeper_session_mgr::instance().resolve_delay_ms()); + dassert(ret == ZOK, "zookeeper set resolve_delay_ms failed."); _watchers.push_back(watcher_object()); _watchers.back().watcher_path = ""; diff --git a/src/rdsn/src/zookeeper/zookeeper_session_mgr.cpp b/src/rdsn/src/zookeeper/zookeeper_session_mgr.cpp index ffad1f2ee9..69325f7364 100644 --- a/src/rdsn/src/zookeeper/zookeeper_session_mgr.cpp +++ b/src/rdsn/src/zookeeper/zookeeper_session_mgr.cpp @@ -48,6 +48,8 @@ zookeeper_session_mgr::zookeeper_session_mgr() _timeout_ms = dsn_config_get_value_uint64( "zookeeper", "timeout_ms", 30000, "zookeeper_timeout_milliseconds"); _zoo_logfile = dsn_config_get_value_string("zookeeper", "logfile", "", "zookeeper logfile"); + _resolve_delay_ms = dsn_config_get_value_uint64( + "zookeeper", "resolve_delay_ms", 0, "zookeeper_resolve_delay_ms"); FILE *fp = fopen(_zoo_logfile.c_str(), "a"); if (fp != nullptr) diff --git a/src/rdsn/src/zookeeper/zookeeper_session_mgr.h b/src/rdsn/src/zookeeper/zookeeper_session_mgr.h index 0f3d18039d..8412c213c6 100644 --- a/src/rdsn/src/zookeeper/zookeeper_session_mgr.h +++ b/src/rdsn/src/zookeeper/zookeeper_session_mgr.h @@ -50,6 +50,7 @@ class zookeeper_session_mgr : public utils::singleton const char *zoo_hosts() const { return _zoo_hosts.c_str(); } int timeout() const { return _timeout_ms; } const char *zoo_logfile() const { return _zoo_logfile.c_str(); } + int resolve_delay_ms() const { return _resolve_delay_ms; } private: zookeeper_session_mgr(); @@ -59,6 +60,7 @@ class zookeeper_session_mgr : public utils::singleton std::string _zoo_hosts; int _timeout_ms; std::string _zoo_logfile; + int _resolve_delay_ms; friend class utils::singleton; }; diff --git a/src/server/config.ini b/src/server/config.ini index 206fc0762b..20ac51b7f8 100644 --- a/src/server/config.ini +++ b/src/server/config.ini @@ -418,6 +418,7 @@ hosts_list = %{zk.server.list} timeout_ms = 10000 logfile = zoo.log + resolve_delay_ms = 0 [task..default] is_trace = false