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
45 changes: 5 additions & 40 deletions storage/eloq/ha_eloq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2724,51 +2724,17 @@ static int eloq_init_func(void *p)
data_store_service_= std::make_unique<EloqDS::DataStoreService>(
ds_config, dss_config_file_path, dss_data_path + "/DSMigrateLog",
std::move(ds_factory));
std::vector<uint32_t> dss_shards= ds_config.GetShardsForThisNode();
std::unordered_map<uint32_t, std::unique_ptr<EloqDS::DataStore>>
dss_shards_map;
// setup rocksdb cloud data store
for (int shard_id : dss_shards)
{
#if defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_S3) || \
defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB_CLOUD_GCS)
// TODO(lzx):move setup datastore to data_store_service
auto ds= std::make_unique<EloqDS::RocksDBCloudDataStore>(
rocksdb_cloud_config, rocksdb_config,
(opt_bootstrap || is_single_node), enable_cache_replacement_,
shard_id, data_store_service_.get());
#elif defined(DATA_STORE_TYPE_ELOQDSS_ROCKSDB)
auto ds= std::make_unique<EloqDS::RocksDBDataStore>(
rocksdb_config, (opt_bootstrap || is_single_node),
enable_cache_replacement_, shard_id, data_store_service_.get());
#elif defined(DATA_STORE_TYPE_ELOQDSS_ELOQSTORE)
auto ds= std::make_unique<EloqDS::EloqStoreDataStore>(
shard_id, data_store_service_.get());
#endif
ds->Initialize();

// Start db if the shard status is not closed
if (ds_config.FetchDSShardStatus(shard_id) !=
EloqDS::DSShardStatus::Closed)
{
bool ret= ds->StartDB();
if (!ret)
{
sql_print_error("Failed to start db instance in data store service");
DBUG_RETURN(eloq_init_abort());
}
}
dss_shards_map[shard_id]= std::move(ds);
}

// setup local data store service
bool ret= data_store_service_->StartService();
// setup local data store service, the data store service will start
// data store if needed.
bool ret=
data_store_service_->StartService((opt_bootstrap || is_single_node));
if (!ret)
Comment on lines +2728 to 2732
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

is_single_node is always true, so clustered nodes now take the single-node start path.

is_single_node is initialized to true above and never flipped to false when we fetch topology from a peer. After this change the expression (opt_bootstrap || is_single_node) therefore always evaluates to true, so every node (including multi-node deployments) now forces the single-node StartService path. That regresses clustered setups that previously relied on the service staying in follower mode. Please compute the actual single-node state (e.g., from the loaded ds_config) before invoking StartService, or pass the existing flag that already encodes it, so clustered nodes don’t wrongly bootstrap themselves.

🤖 Prompt for AI Agents
In storage/eloq/ha_eloq.cc around lines 2705-2709, is_single_node is initialized
to true earlier and never updated, so the expression (opt_bootstrap ||
is_single_node) always evaluates to true and forces single-node StartService;
update the code to compute the real single-node state before calling
StartService by deriving it from the loaded ds_config (or use the existing flag
that already encodes cluster membership) — e.g., set is_single_node = (ds_config
indicates no peers / cluster size == 1) or use the provided cluster flag, then
call data_store_service_->StartService((opt_bootstrap || is_single_node)) so
only genuine single-node deployments take the single-node path.

{
sql_print_error("Failed to start data store service");
DBUG_RETURN(eloq_init_abort());
}
data_store_service_->ConnectDataStore(std::move(dss_shards_map));

// setup data store service client
storage_hd= std::make_unique<EloqDS::DataStoreServiceClient>(
catalog_factory, ds_config, data_store_service_.get());
Expand Down Expand Up @@ -3304,7 +3270,6 @@ static int eloq_done_func(void *p)
#if ELOQDS
if (data_store_service_ != nullptr)
{
data_store_service_->DisconnectDataStore();
data_store_service_= nullptr;
}
#endif
Expand Down