diff --git a/.gitignore b/.gitignore index de9ce42c..c0813a19 100644 --- a/.gitignore +++ b/.gitignore @@ -358,3 +358,4 @@ compile_commands.json cmake-build-debug/ .cache +_codeql_detected_source_root diff --git a/tx_service/src/sharder.cpp b/tx_service/src/sharder.cpp index d59980b3..ee892cb3 100644 --- a/tx_service/src/sharder.cpp +++ b/tx_service/src/sharder.cpp @@ -213,6 +213,29 @@ int Sharder::Init( if (log_agent_ != nullptr) { log_agent_->Init(txlog_ips_, txlog_ports_, 0); + // Refresh leader information for all log groups immediately after + // initialization to ensure we have current leader info, especially + // important after cluster restart when leaders may have changed. + uint32_t log_group_count = log_agent_->LogGroupCount(); + if (log_group_count == 0) + { + LOG(WARNING) + << "No log groups found after log agent initialization. " + "Log service may not be properly configured."; + } + else + { + LOG(INFO) << "Refreshing leader info for " << log_group_count + << " log group(s) after initialization"; + for (uint32_t lg_id = 0; lg_id < log_group_count; ++lg_id) + { + // RefreshLeader is typically a lightweight operation that + // updates internal cache. The log service will handle any + // connection issues gracefully with retries. + log_agent_->RefreshLeader(lg_id); + DLOG(INFO) << "Refreshed leader for log group " << lg_id; + } + } } #ifdef EXT_TX_PROC_ENABLED