From ccf26b4da969dcce473b580347ec65e4e02bd754 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Fri, 11 Oct 2024 14:29:40 +0800 Subject: [PATCH] refactor(meta): use in-memory sqlite for `Mem` meta backend --- src/cmd_all/src/single_node.rs | 4 +++- src/meta/node/src/lib.rs | 2 +- src/meta/src/backup_restore/utils.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd_all/src/single_node.rs b/src/cmd_all/src/single_node.rs index 5495be878202b..a84fd0470a5be 100644 --- a/src/cmd_all/src/single_node.rs +++ b/src/cmd_all/src/single_node.rs @@ -182,7 +182,9 @@ pub fn map_single_node_opts_to_standalone_opts(opts: SingleNodeOpts) -> ParsedSt }; if !meta_backend_is_set { if opts.in_memory { - meta_opts.backend = Some(MetaBackend::Mem); + meta_opts.backend = Some(MetaBackend::Sqlite); + meta_opts.sql_endpoint = + Some("meta_backend?mode=memory&cache=shared".to_owned().into()); } else { meta_opts.backend = Some(MetaBackend::Sqlite); let meta_store_dir = format!("{}/meta_store", &store_directory); diff --git a/src/meta/node/src/lib.rs b/src/meta/node/src/lib.rs index 633093b2c7024..3b12899c6bd9e 100644 --- a/src/meta/node/src/lib.rs +++ b/src/meta/node/src/lib.rs @@ -271,7 +271,7 @@ pub fn start( }, MetaBackend::Sqlite => MetaStoreBackend::Sql { endpoint: format!( - "sqlite://{}?mode=rwc", + "sqlite://{}", opts.sql_endpoint .expect("sql endpoint is required") .expose_secret() diff --git a/src/meta/src/backup_restore/utils.rs b/src/meta/src/backup_restore/utils.rs index 4c4c9a336b449..1c588f3a9fcd8 100644 --- a/src/meta/src/backup_restore/utils.rs +++ b/src/meta/src/backup_restore/utils.rs @@ -66,7 +66,7 @@ pub async fn get_meta_store(opts: RestoreOpts) -> BackupResult MetaStoreBackend::Sql { - endpoint: format!("sqlite://{}?mode=rwc", opts.sql_endpoint), + endpoint: format!("sqlite://{}", opts.sql_endpoint), }, MetaBackend::Postgres => MetaStoreBackend::Sql { endpoint: format!(