Skip to content

Commit

Permalink
Merge pull request #1898 from tursodatabase/lucio/disable-checkpointi…
Browse files Browse the repository at this point in the history
…ng-bottomless

sqld: disable checkpoint on primary conn create
  • Loading branch information
LucioFranco authored Jan 6, 2025
2 parents 5beaf27 + d95fe5d commit 3497d8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions bottomless/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,14 @@ impl Replicator {
})?;
tracing::trace!("Local change counter: {change_counter}");

// TODO: we shouldn't leak the connection here but for some reason when this connection get
// dropped it seems to checkpoint the database
if std::env::var("LIBSQL_BOTTOMLESS_DISABLE_INIT_CHECKPOINTING").is_ok()
|| std::env::var("LIBSQL_DISABLE_INIT_CHECKPOINTING").is_ok()
{
std::mem::forget(conn);
}

Ok(change_counter.to_be_bytes())
}

Expand Down
13 changes: 10 additions & 3 deletions libsql-server/src/namespace/configurator/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ pub(super) async fn make_primary_connection_maker(

let bottomless_replicator = match primary_config.bottomless_replication {
Some(ref options) => {
tracing::debug!("Checkpointing before initializing bottomless");
crate::replication::primary::logger::checkpoint_db(&db_path.join("data"))?;
tracing::debug!("Checkpointed before initializing bottomless");
// TODO: figure out why we really need this the fixme above is not clear enough but
// disabling this allows us to prevent checkpointing of the wal file.
if !std::env::var("LIBSQL_DISABLE_INIT_CHECKPOINTING").is_ok() {
tracing::debug!("Checkpointing before initializing bottomless");
crate::replication::primary::logger::checkpoint_db(&db_path.join("data"))?;
tracing::debug!("Checkpointed before initializing bottomless");
} else {
tracing::warn!("Disabling initial checkpoint before bottomless");
}

let options = make_bottomless_options(options, bottomless_db_id, name.clone());
let (replicator, did_recover) =
init_bottomless_replicator(db_path.join("data"), options, &restore_option).await?;
Expand Down

0 comments on commit 3497d8a

Please sign in to comment.