diff --git a/include/libnuraft/raft_params.hxx b/include/libnuraft/raft_params.hxx index d5d1be44..86dddb38 100644 --- a/include/libnuraft/raft_params.hxx +++ b/include/libnuraft/raft_params.hxx @@ -223,11 +223,11 @@ struct raft_params { } /** - * Timeout for syncing the snapshot requests. - * - * @param timeout_ms - * @return self - */ + * Timeout for syncing the snapshot requests. + * + * @param timeout_ms + * @return self + */ raft_params& with_snapshot_sync_ctx_timeout(int32 timeout_ms) { snapshot_sync_ctx_timeout_ = timeout_ms; return *this; @@ -418,10 +418,11 @@ public: int32 snapshot_block_size_; /** - * Timeout(ms) for snapshot_sync_ctx, if a single snapshot syncing request exceeds this, - * it will be considered as timeout and ctx will be released. - * 0 means it will be set to the default value `heart_beat_interval_ * response_limit_`. - */ + * Timeout(ms) for snapshot_sync_ctx, if a single snapshot syncing request + * exceeds this, it will be considered as timeout and ctx will be released. + * 0 means it will be set to the default value + * `heart_beat_interval_ * response_limit_`. + */ int32 snapshot_sync_ctx_timeout_; /** diff --git a/src/handle_join_leave.cxx b/src/handle_join_leave.cxx index 48648f07..0425c56d 100644 --- a/src/handle_join_leave.cxx +++ b/src/handle_join_leave.cxx @@ -91,8 +91,11 @@ ptr raft_server::handle_add_srv_req(req_msg& req) { srv_to_join_->get_id(), last_active_ms); - ulong sync_timeout = (ulong)raft_limits_.response_limit_ - * ctx_->get_params()->heart_beat_interval_; + // NOTE: + // If snapshot transmission was in progress, we will follow the + // snapshot timeout. Otherwise, we will follow the response timeout. + ulong sync_timeout = (ulong)raft_limits_.response_limit_ * + ctx_->get_params()->heart_beat_interval_; if (srv_to_join_->get_snapshot_sync_ctx()) { sync_timeout = (ulong)get_snapshot_sync_ctx_timeout(); }