Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqld: disable checkpoint on primary conn create #1898

Merged
merged 1 commit into from
Jan 6, 2025
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
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this safe? @penberg @sivukhin May I borrow your brains here? Isn't leaking sqlite connection leading to some disaster over time?

}

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
Loading