You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by zi...@apache.org on 2022/08/25 03:55:34 UTC
[inlong] branch release-1.3.0 updated: [INLONG-5681][TubeMQ] The C++ SDK does not switch after the active Master node hangs up (#5682)
This is an automated email from the ASF dual-hosted git repository.
zirui pushed a commit to branch release-1.3.0
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/release-1.3.0 by this push:
new f63ebf9f3 [INLONG-5681][TubeMQ] The C++ SDK does not switch after the active Master node hangs up (#5682)
f63ebf9f3 is described below
commit f63ebf9f3044798928432a63b74d094299821798
Author: Goson Zhang <46...@qq.com>
AuthorDate: Thu Aug 25 11:54:13 2022 +0800
[INLONG-5681][TubeMQ] The C++ SDK does not switch after the active Master node hangs up (#5682)
---
.../tubemq-client-cpp/src/baseconsumer.cc | 16 +++++++++++++---
.../tubemq-client-cpp/src/const_config.h | 2 ++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/baseconsumer.cc b/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/baseconsumer.cc
index 3012fe2d2..25001de2b 100644
--- a/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/baseconsumer.cc
+++ b/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/baseconsumer.cc
@@ -526,6 +526,15 @@ void BaseConsumer::heartBeat2Master() {
master_sh_retry_cnt_++;
LOG_WARN("[CONSUMER] heartBeat2Master failue to (%s:%d) : %s, client=%s",
target_ip.c_str(), target_port, error.Message().c_str(), client_uuid_.c_str());
+ if (master_sh_retry_cnt_ >= tb_config::kMaxMasterHBRetryCount) {
+ LOG_WARN("[CONSUMER] heartBeat2Master found over max-hb-retry(%d), client=%s",
+ master_sh_retry_cnt_, client_uuid_.c_str());
+ master_sh_retry_cnt_ = 0;
+ is_master_actived_.Set(false);
+ asyncRegister2Master(true);
+ master_hb_status_.CompareAndSet(1, 0);
+ return;
+ }
} else {
// process response
auto rsp = any_cast<TubeMQCodec::RspProtocolPtr>(response_context.rsp_);
@@ -540,9 +549,10 @@ void BaseConsumer::heartBeat2Master() {
if (error_code == err_code::kErrHbNoNode ||
error_info.find("StandbyException") != string::npos) {
is_master_actived_.Set(false);
- LOG_WARN("[CONSUMER] hb2master found no-node or standby, re-register, client=%s",
- client_uuid_.c_str());
- asyncRegister2Master(!(error_code == err_code::kErrHbNoNode));
+ bool need_change = !(error_code == err_code::kErrHbNoNode);
+ LOG_WARN("[CONSUMER] heartBeat2Master found no-node or standby, client=%s, change=%d",
+ client_uuid_.c_str(), need_change);
+ asyncRegister2Master(need_change);
master_hb_status_.CompareAndSet(1, 0);
return;
}
diff --git a/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/const_config.h b/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/const_config.h
index c854548e8..e6e4bf371 100644
--- a/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/const_config.h
+++ b/inlong-tubemq/tubemq-client-twins/tubemq-client-cpp/src/const_config.h
@@ -59,6 +59,8 @@ static const int32_t kRpcTimoutMinMs = 8000;
static const int32_t kHeartBeatPeriodDefMs = 10000;
static const int32_t kHeartBeatFailRetryTimesDef = 5;
static const int32_t kHeartBeatSleepPeriodDefMs = 60000;
+// default max master hb retry count
+static const int32_t kMaxMasterHBRetryCount = 8;
// max masterAddrInfo length
static const int32_t kMasterAddrInfoMaxLength = 1024;