Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions src/redis_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,45 @@ bool RedisServiceImpl::Init(brpc::Server &brpc_server)
std::filesystem::create_directories(eloq_dss_data_path);
}

std::string dss_config_file_path =
eloq_dss_data_path + "/dss_config.ini";
std::string dss_config_file_path = "";
EloqDS::DataStoreServiceClusterManager ds_config;
uint32_t dss_leader_id = EloqDS::UNKNOWN_DSS_LEADER_NODE_ID;

// use tx node id as the dss node id
// since they are deployed together
uint32_t dss_node_id = node_id;
if (FLAGS_bootstrap || is_single_node)
{
dss_leader_id = node_id;
}

if (!eloq_dss_peer_node.empty())
{
ds_config.SetThisNode(
local_ip,
EloqDS::DataStoreServiceClient::TxPort2DssPort(local_tx_port));
// Fetch ds topology from peer node
if (!EloqDS::DataStoreService::FetchConfigFromPeer(
eloq_dss_peer_node, ds_config))
{
LOG(ERROR) << "Failed to fetch config from peer node: "
<< eloq_dss_peer_node;
return false;
}
}
else
{
EloqDS::DataStoreServiceClient::TxConfigsToDssClusterConfig(
dss_node_id,
native_ng_id,
ng_configs,
dss_leader_id,
ds_config);
}
Comment on lines +1048 to +1054
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add error handling for TxConfigsToDssClusterConfig.

The call to TxConfigsToDssClusterConfig lacks error handling, unlike the peer fetch path (lines 1038-1044). If this function can fail, add appropriate error checking and return false on failure to maintain consistency with the peer fetch error handling.

🤖 Prompt for AI Agents
In src/redis_service.cpp around lines 1048 to 1054, the call to
EloqDS::DataStoreServiceClient::TxConfigsToDssClusterConfig has no error
handling; mirror the peer-fetch path at lines 1038–1044 by checking the
function's return value, logging a clear error (including context such as
dss_node_id/native_ng_id) when it fails, and returning false from the
surrounding function on failure so behavior is consistent with the peer fetch
error handling.


// std::string dss_config_file_path =
// eloq_dss_data_path + "/dss_config.ini";
/*
EloqDS::DataStoreServiceClusterManager ds_config;
if (std::filesystem::exists(dss_config_file_path))
{
Expand Down Expand Up @@ -1071,6 +1107,7 @@ bool RedisServiceImpl::Init(brpc::Server &brpc_server)
return false;
}
}
*/

#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3) || \
defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_GCS)
Expand Down Expand Up @@ -1104,7 +1141,7 @@ bool RedisServiceImpl::Init(brpc::Server &brpc_server)
// Start data store service. (Also create datastore in StartService() if
// needed)
bool ret = data_store_service_->StartService(
(FLAGS_bootstrap || is_single_node));
(FLAGS_bootstrap || is_single_node), dss_leader_id, dss_node_id);
if (!ret)
{
LOG(ERROR) << "Failed to start data store service";
Expand All @@ -1121,7 +1158,9 @@ bool RedisServiceImpl::Init(brpc::Server &brpc_server)
store_hd_->AppendPreBuiltTable(table_name);
}

if (!store_hd_->Connect())
// do connect only when this is bootstrap or single node
// otherwise, connect when become leader or follower
if ((FLAGS_bootstrap || is_single_node) && !store_hd_->Connect())
{
LOG(ERROR) << "!!!!!!!! Failed to connect to kvstore, startup is "
"terminated !!!!!!!!";
Expand Down
2 changes: 1 addition & 1 deletion tx_service