feat(local): set WAL journal mode as default for local databases (fixes #1553) - #2280
Open
Aditya-9-6 wants to merge 2 commits into
Open
feat(local): set WAL journal mode as default for local databases (fixes #1553)#2280Aditya-9-6 wants to merge 2 commits into
Aditya-9-6 wants to merge 2 commits into
Conversation
tursodatabase#1553) - Sets SQLite journal mode to WAL (PRAGMA journal_mode = WAL) by default when opening local file-based database connections. - Safely skips setting WAL mode for in-memory (:memory:) databases and read-only connections (SQLITE_OPEN_READONLY). - Adds integration tests verifying default WAL mode, in-memory databases, and read-only connections. - Gates pprof under cfg(not(windows)) in dev-dependencies to support building and testing on Windows.
…tabases - Moves PRAGMA journal_mode = WAL execution to DbType::File after encryption cipher and key are set. - Restores Connection::connect to avoid executing SQL before encryption keys are applied to raw SQLite handles, fixing 'file is not a database' on encrypted databases and embedded replicas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1553.
Problem
Turso's server, platform, and embedded replicas all use Write-Ahead Logging (
WAL) mode. However, standalone and local file-based database connections in thelibsqlRust driver did not enable WAL mode by default, leaving databases inDELETEjournal mode unless explicitly configured.Solution
PRAGMA journal_mode = WALupon establishing local file-based database connections inConnection::connect.:memory:or temporary empty paths), which do not support WAL mode and will gracefully remain inmemoryjournal mode.SQLITE_OPEN_READONLY), avoidingSQLITE_READONLY: attempt to write a readonly databaseerrors when opening existing read-only database files.pprofunder[target.'cfg(not(windows))'.dev-dependencies]inlibsql/Cargo.tomlso Windows developers can build and run tests without compilation failures.libsql/tests/integration_tests.rs:test_default_journal_mode_is_wal: asserts that bothBuilder::new_localandDatabase::opendefault to WAL mode.test_memory_journal_mode_is_memory: verifies:memory:databases succeed and report"memory".test_readonly_connection_succeeds: verifies opening databases withOpenFlags::SQLITE_OPEN_READ_ONLYsucceeds and preserves WAL mode without attempting invalid header writes.