Skip to content

Commit 11066a4

Browse files
committed
cleanup libsql namespaces
1 parent 1ea3f3d commit 11066a4

3 files changed

Lines changed: 22 additions & 25 deletions

File tree

libsql-server/src/namespace/configurator/libsql_primary.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::schema::{has_pending_migration_task, setup_migration_table};
2525
use crate::stats::Stats;
2626
use crate::{SqldStorage, DB_CREATE_TIMEOUT, DEFAULT_AUTO_CHECKPOINT};
2727

28+
use super::helpers::cleanup_libsql;
2829
use super::{BaseNamespaceConfig, ConfigureNamespace, PrimaryConfig};
2930

3031
pub struct LibsqlPrimaryConfigurator {
@@ -248,12 +249,16 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator {
248249

249250
fn cleanup<'a>(
250251
&'a self,
251-
_namespace: &'a NamespaceName,
252+
namespace: &'a NamespaceName,
252253
_db_config: &'a DatabaseConfig,
253254
_prune_all: bool,
254255
_bottomless_db_id_init: NamespaceBottomlessDbIdInit,
255256
) -> Pin<Box<dyn Future<Output = crate::Result<()>> + Send + 'a>> {
256-
unimplemented!()
257+
Box::pin(cleanup_libsql(
258+
namespace,
259+
&self.registry,
260+
&self.base.base_path,
261+
))
257262
}
258263

259264
fn fork<'a>(

libsql-server/src/namespace/configurator/libsql_replica.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::namespace::{
2929
};
3030
use crate::{SqldStorage, DB_CREATE_TIMEOUT};
3131

32+
use super::helpers::cleanup_libsql;
3233
use super::{BaseNamespaceConfig, ConfigureNamespace};
3334

3435
pub struct LibsqlReplicaConfigurator {
@@ -251,14 +252,11 @@ impl ConfigureNamespace for LibsqlReplicaConfigurator {
251252
_prune_all: bool,
252253
_bottomless_db_id_init: NamespaceBottomlessDbIdInit,
253254
) -> Pin<Box<dyn Future<Output = crate::Result<()>> + Send + 'a>> {
254-
Box::pin(async move {
255-
let ns_path = self.base.base_path.join("dbs").join(namespace.as_str());
256-
if ns_path.try_exists()? {
257-
tracing::debug!("removing database directory: {}", ns_path.display());
258-
tokio::fs::remove_dir_all(ns_path).await?;
259-
}
260-
Ok(())
261-
})
255+
Box::pin(cleanup_libsql(
256+
namespace,
257+
&self.registry,
258+
&self.base.base_path,
259+
))
262260
}
263261

264262
fn fork<'a>(

libsql-server/src/namespace/configurator/libsql_schema.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::namespace::{
1616
use crate::schema::SchedulerHandle;
1717
use crate::SqldStorage;
1818

19-
use super::helpers::cleanup_primary;
19+
use super::helpers::cleanup_libsql;
2020
use super::libsql_primary::{libsql_primary_common, LibsqlPrimaryCommon};
2121
use super::{BaseNamespaceConfig, ConfigureNamespace, PrimaryConfig};
2222

@@ -146,21 +146,15 @@ impl ConfigureNamespace for LibsqlSchemaConfigurator {
146146
fn cleanup<'a>(
147147
&'a self,
148148
namespace: &'a NamespaceName,
149-
db_config: &'a DatabaseConfig,
150-
prune_all: bool,
151-
bottomless_db_id_init: crate::namespace::NamespaceBottomlessDbIdInit,
149+
_db_config: &'a DatabaseConfig,
150+
_prune_all: bool,
151+
_bottomless_db_id_init: crate::namespace::NamespaceBottomlessDbIdInit,
152152
) -> std::pin::Pin<Box<dyn Future<Output = crate::Result<()>> + Send + 'a>> {
153-
Box::pin(async move {
154-
cleanup_primary(
155-
&self.base,
156-
&self.primary_config,
157-
namespace,
158-
db_config,
159-
prune_all,
160-
bottomless_db_id_init,
161-
)
162-
.await
163-
})
153+
Box::pin(cleanup_libsql(
154+
namespace,
155+
&self.registry,
156+
&self.base.base_path,
157+
))
164158
}
165159

166160
fn fork<'a>(

0 commit comments

Comments
 (0)