Skip to content

Commit e3e6fbf

Browse files
committed
fix single node start
1 parent fcd3636 commit e3e6fbf

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

storage/eloq/ha_eloq.cc

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,8 @@ static int eloq_init_func(void *p)
26602660

26612661
#elif ELOQDS
26622662
case KV_ELOQDS: {
2663-
bool is_single_node= true;
2663+
bool is_single_node=
2664+
(ng_configs.size() == 1 && ng_configs.begin()->second.size() == 1);
26642665
std::string ds_peer_node= eloq_dss_peer_node;
26652666
std::string ds_branch_name= eloq_dss_branch_name;
26662667
std::string dss_data_path= mysql_real_data_home_ptr;
@@ -2741,18 +2742,43 @@ static int eloq_init_func(void *p)
27412742
}
27422743
else
27432744
{
2744-
// Bind dss with TxService.
2745+
// Bind dss leaders with TxService ng leaders.
27452746
std::unordered_map<uint32_t, uint32_t> ng_leaders;
2747+
27462748
if (opt_bootstrap || is_single_node)
27472749
{
2750+
// Must parse all node groups to generate data store shards configs.
2751+
std::unordered_map<uint32_t, std::vector<NodeConfig>> tmp_ng_configs;
2752+
if (!txservice::ReadClusterConfigFile(
2753+
cluster_config_file, tmp_ng_configs, cluster_config_version))
2754+
{
2755+
2756+
// Read cluster topology from general config file in this case
2757+
auto parse_res= txservice::ParseNgConfig(
2758+
eloq_ip_list, eloq_standby_ip_list, eloq_voter_ip_list,
2759+
tmp_ng_configs, eloq_node_group_replica_num, 0);
2760+
if (!parse_res)
2761+
{
2762+
LOG(ERROR)
2763+
<< "Failed to extract cluster configs from ip_port_list.";
2764+
DBUG_RETURN(eloq_init_abort());
2765+
}
2766+
}
2767+
27482768
// For bootstrap, start all data store shards in current node.
2749-
for (auto &ng : ng_configs)
2769+
for (auto &ng : tmp_ng_configs)
27502770
{
27512771
ng_leaders.emplace(ng.first, node_id);
27522772
}
2773+
2774+
EloqDS::DataStoreServiceClient::TxConfigsToDssClusterConfig(
2775+
node_id, tmp_ng_configs, ng_leaders, ds_config);
2776+
}
2777+
else
2778+
{
2779+
EloqDS::DataStoreServiceClient::TxConfigsToDssClusterConfig(
2780+
node_id, ng_configs, ng_leaders, ds_config);
27532781
}
2754-
EloqDS::DataStoreServiceClient::TxConfigsToDssClusterConfig(
2755-
node_id, ng_configs, ng_leaders, ds_config);
27562782
}
27572783

27582784
data_store_service_= std::make_unique<EloqDS::DataStoreService>(

0 commit comments

Comments
 (0)