Skip to content

Commit 110437a

Browse files
authored
chore: remove unused config_id from RaftConfig (#16902)
* chore: optimize meta-service initialization Try initialize instead of check `is_open` flag. This flag may not be accurate: the raft storage is opend but no initialization is done yet. And remove trait `Opened` and refactor related struct names * chore: remove unused config_id from RaftConfig `config_id` is used for separate sled-db key spaces for parallel tests. Since sled db is removed, this `config_id` is useless.
1 parent d38c91c commit 110437a

File tree

18 files changed

+140
-140
lines changed

18 files changed

+140
-140
lines changed

src/meta/binaries/meta/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub async fn entry(conf: Config) -> anyhow::Result<()> {
197197
}
198198

199199
async fn do_register(meta_node: &Arc<MetaNode>, conf: &Config) -> Result<(), MetaAPIError> {
200-
let node_id = meta_node.sto.id;
200+
let node_id = meta_node.raft_store.id;
201201
let raft_endpoint = conf.raft_config.raft_api_advertise_host_endpoint();
202202
let node = Node::new(node_id, raft_endpoint)
203203
.with_grpc_advertise_address(conf.grpc_api_advertise_address());

src/meta/binaries/metactl/export_from_disk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::io::Write;
1717
use std::sync::Arc;
1818

1919
use databend_common_meta_raft_store::config::RaftConfig;
20-
use databend_meta::store::StoreInner;
20+
use databend_meta::store::RaftStoreInner;
2121
use futures::TryStreamExt;
2222

2323
use crate::upgrade;
@@ -36,7 +36,7 @@ pub async fn export_from_dir(args: &ExportArgs) -> anyhow::Result<()> {
3636
eprintln!();
3737
eprintln!("Export:");
3838

39-
let sto_inn = StoreInner::open(&raft_config).await?;
39+
let sto_inn = RaftStoreInner::open(&raft_config).await?;
4040
let mut lines = Arc::new(sto_inn).export();
4141

4242
eprintln!(" From: {}", raft_config.raft_dir);

src/meta/service/src/api/grpc/grpc_service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl MetaService for MetaServiceImpl {
362362
let _guard = RequestInFlight::guard();
363363

364364
let meta_node = &self.meta_node;
365-
let strm = meta_node.sto.inner().export();
365+
let strm = meta_node.raft_store.inner().export();
366366

367367
let chunk_size = 32;
368368
// - Chunk up upto 32 Ok items inside a Vec<String>;
@@ -390,7 +390,7 @@ impl MetaService for MetaServiceImpl {
390390
let _guard = RequestInFlight::guard();
391391

392392
let meta_node = &self.meta_node;
393-
let strm = meta_node.sto.inner().export();
393+
let strm = meta_node.raft_store.inner().export();
394394

395395
let chunk_size = request.get_ref().chunk_size.unwrap_or(32) as usize;
396396
// - Chunk up upto `chunk_size` Ok items inside a Vec<String>;

src/meta/service/src/configs/outer_v0.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ pub struct ConfigViaEnv {
279279
pub grpc_tls_server_cert: String,
280280
pub grpc_tls_server_key: String,
281281

282-
pub config_id: String,
283282
pub kvsrv_listen_host: String,
284283
pub kvsrv_advertise_host: String,
285284
pub kvsrv_api_port: u16,
@@ -338,7 +337,6 @@ impl From<Config> for ConfigViaEnv {
338337
metasrv_grpc_api_advertise_host: cfg.grpc_api_advertise_host,
339338
grpc_tls_server_cert: cfg.grpc_tls_server_cert,
340339
grpc_tls_server_key: cfg.grpc_tls_server_key,
341-
config_id: cfg.raft_config.config_id,
342340
kvsrv_listen_host: cfg.raft_config.raft_listen_host,
343341
kvsrv_advertise_host: cfg.raft_config.raft_advertise_host,
344342
kvsrv_api_port: cfg.raft_config.raft_api_port,
@@ -377,7 +375,6 @@ impl From<Config> for ConfigViaEnv {
377375
impl Into<Config> for ConfigViaEnv {
378376
fn into(self) -> Config {
379377
let raft_config = RaftConfig {
380-
config_id: self.config_id,
381378
raft_listen_host: self.kvsrv_listen_host,
382379
raft_advertise_host: self.kvsrv_advertise_host,
383380
raft_api_port: self.kvsrv_api_port,
@@ -457,11 +454,6 @@ impl Into<Config> for ConfigViaEnv {
457454
#[clap(about, version, author)]
458455
#[serde(default)]
459456
pub struct RaftConfig {
460-
/// Identify a config.
461-
/// This is only meant to make debugging easier with more than one Config involved.
462-
#[clap(long, default_value = "")]
463-
pub config_id: String,
464-
465457
/// The local listening host for metadata communication.
466458
/// This config does not need to be stored in raft-store,
467459
/// only used when metasrv startup and listen to.
@@ -610,7 +602,7 @@ impl Default for RaftConfig {
610602
impl From<RaftConfig> for InnerRaftConfig {
611603
fn from(x: RaftConfig) -> InnerRaftConfig {
612604
InnerRaftConfig {
613-
config_id: x.config_id,
605+
config_id: "".to_string(),
614606
raft_listen_host: x.raft_listen_host,
615607
raft_advertise_host: x.raft_advertise_host,
616608
raft_api_port: x.raft_api_port,
@@ -649,7 +641,6 @@ impl From<RaftConfig> for InnerRaftConfig {
649641
impl From<InnerRaftConfig> for RaftConfig {
650642
fn from(inner: InnerRaftConfig) -> Self {
651643
Self {
652-
config_id: inner.config_id,
653644
raft_listen_host: inner.raft_listen_host,
654645
raft_advertise_host: inner.raft_advertise_host,
655646
raft_api_port: inner.raft_api_port,

src/meta/service/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ pub(crate) mod request_handling;
2727
pub mod store;
2828
pub mod version;
2929
pub mod watcher;
30-
31-
pub trait Opened {
32-
/// Return true if it is opened from a previous persistent state.
33-
/// Otherwise it is just created.
34-
fn is_opened(&self) -> bool;
35-
}

src/meta/service/src/meta_service/forwarder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct MetaForwarder<'a> {
4747
impl<'a> MetaForwarder<'a> {
4848
pub fn new(meta_node: &'a MetaNode) -> Self {
4949
Self {
50-
sto: &meta_node.sto,
50+
sto: &meta_node.raft_store,
5151
raft: &meta_node.raft,
5252
}
5353
}

src/meta/service/src/meta_service/meta_leader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a> Handler<MetaGrpcReadReq> for MetaLeader<'a> {
167167
impl<'a> MetaLeader<'a> {
168168
pub fn new(meta_node: &'a MetaNode) -> MetaLeader {
169169
MetaLeader {
170-
sto: &meta_node.sto,
170+
sto: &meta_node.raft_store,
171171
raft: &meta_node.raft,
172172
}
173173
}

0 commit comments

Comments
 (0)