Skip to content

libsql: expose Connection::wal_disable_checkpoint - #2306

Open
ki7dk wants to merge 1 commit into
tursodatabase:mainfrom
ki7dk:expose-wal-disable-checkpoint
Open

ki7dk wants to merge 1 commit into
tursodatabase:mainfrom
ki7dk:expose-wal-disable-checkpoint

Conversation

@ki7dk

@ki7dk ki7dk commented Oct 28, 2026

Copy link
Copy Markdown

The local connection already wraps libsql_wal_disable_checkpoint, and sync databases call it when they connect, but the method is private, so there's no way to reach it from a libsql::Connection.

We need it because we read frames out of the WAL with libsql_wal_get_frame and ship them to a second machine. PRAGMA wal_autocheckpoint = 0 isn't enough for that. It stops the checkpoint after commits, but SQLite still checkpoints when the last connection closes, and any frames we haven't shipped yet end up in the database file.

This exposes it the same way as set_reserved_bytes: a default on Conn that returns a new Error::WalDisableCheckpointNotSupported, and the local connection forwards to the existing method. Remote, replica and sync connections return the error. Error is #[non_exhaustive], so the new variant shouldn't break anyone.

Turso has the same function in its C bindings (it's in the "Turso-specific Extensions" table in COMPAT.md), and its doc comment draws the same line between it and sqlite3_wal_autocheckpoint().

The test closes a WAL database with checkpointing disabled, checks that the -wal file is still there, and reads the row back. It fails if the method only sets the pragma.

We've been running this as a patch on 0.9.30 since September.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant