Skip to content

Enable WAL mode in libSQL - #27

Merged
glguida merged 5 commits into
masterfrom
copilot/enable-wal-in-libsql
Jan 3, 2026
Merged

glguida merged 5 commits into
masterfrom
copilot/enable-wal-in-libsql

Conversation

Copilot AI commented Jan 3, 2026 •

Copy link
Copy Markdown
Contributor

Enable WAL (Write-Ahead Logging) mode in libSQL for better performance and concurrency

  • Explore repository structure and understand libSQL usage
  • Identify where database connections are established
  • Research libSQL WAL mode configuration
  • Enable WAL mode in VectorDatabaseConnection initialization
  • Add test to verify WAL mode is enabled
  • Run existing tests to ensure no regression
  • Verify code formatting and linting
  • Address code review feedback
    • Added comment about in-memory database behavior
    • Created test-only helper method to avoid accessing private fields
    • Properly consume query result to ensure command succeeded
    • Added documentation links for SQLite WAL and PRAGMA journal_mode
    • Clarified why query() is used instead of execute() for PRAGMA journal_mode
  • Final verification complete

Summary

This PR enables Write-Ahead Logging (WAL) mode in libSQL, providing:

  • Better write concurrency: Multiple readers can access the database while a write is in progress
  • Improved performance: WAL mode is generally faster for most workloads
  • Better crash recovery: Changes are written to a separate WAL file first, providing better durability

Changes Made:

  1. Enable WAL mode when creating database connections in VectorDatabaseConnection::new()
  2. Added test to verify WAL mode is properly enabled on file-based databases
  3. Added tempfile as a dev dependency for testing
  4. Added test-only helper method get_journal_mode() for clean testing without accessing private fields
  5. Properly consume the PRAGMA journal_mode result to ensure the command succeeded
  6. Added documentation links to SQLite documentation

Notes:

  • WAL mode is not available for in-memory databases (:memory:), which will continue using the default journal mode
  • All existing tests pass without modification, confirming backward compatibility
  • The change is minimal and focused solely on enabling WAL mode
  • PRAGMA journal_mode returns a result row, so we use query() instead of execute()
Original prompt

This section details on the original issue you should resolve

<issue_title>Enable WAL in libSQL</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 3, 2026 14:36
Co-authored-by: glguida <136059+glguida@users.noreply.github.com>
…lementation

Co-authored-by: glguida <136059+glguida@users.noreply.github.com>
Co-authored-by: glguida <136059+glguida@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable WAL in libSQL Enable WAL mode in libSQL Jan 3, 2026
Copilot AI requested a review from glguida January 3, 2026 14:45
Comment thread src/vectordb.rs Outdated
// Note: WAL mode is not available for in-memory databases, which will
// continue using the default journal mode. This is expected and acceptable.
// PRAGMA journal_mode returns the mode that was actually set, so we consume
// the result to ensure the command succeeded.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot link to documentation to this behaviour?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added documentation links and clarified that PRAGMA journal_mode returns a result row, which is why we must use query() instead of execute() (which expects no result rows). See commit 362cf4c.

Co-authored-by: glguida <136059+glguida@users.noreply.github.com>

Copilot AI commented Jan 3, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.08aw66x40qgorx91nnehisvlm.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.08viz024rraf7j8rpjz8hy7ub.17wgvfs.rcgu.o 64-REDACTED-linux-gnu/bin/rust-lld /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0bsubv65ed0jq82w4cqgh17j5.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0c51xbxuscucqtvviteh2h23g.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0du4uorqwitbhr5yi0kdd80kz.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0e6b3hzoagb2byyu5mmnt1fd5.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0gxixnbdq3q66e0my4i194h6e.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0hzjve44nmxvc�� /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0j5eg677qegkulc7hrho4alxa.17wgvfs.rcgu.o /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825.0k5vb3bvw524ia2n0rtw67exd.17wgvfs.rcgu.o rget�� /onig_sys-02b54c/home/REDACTED/work/capsa/capsa/target/debug/build/rustix-e375fcd5d50c4657/build_sgit /onig_sys-02b54c/home/REDACTED/work/capsa/capsa/target/debug/build/rustix-e375fcd5d50c4657/build_sadd bin/rustc regerror.o 1 _H=1 bin/rustc (dns block)
    • Triggering command: /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 cfg(feature, values(&#34;web_spin_lock&#34;)) -C metadata=e9eaaf4404651684 (dns block)
    • Triggering command: /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 /home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-4c264a59688d8825 cfg(feature, values(&#34;encryption&#34;)) -C metadata=7028aae59f4ed804 AESv�� rget/debug/deps//home/REDACTED/work/capsa/capsa/target/debug/build/libsql-sqlite3-parser-e0b30187e/home/REDACTED/work/capsa/capsa/target/debug/deps/capsa-05c0df57dd8cc7d3 b5ae476e1c7/buil/home/REDACTED/work/capsa/capsa/target/debug/build/libsql-sqlite3-parser-e0b30187e4067b66/build_script_build-e0b30187e4067b66.build_script_build.552d44bf2bc0c1bf--j b5ae476e1c7/buil/home/REDACTED/work/capsa/capsa/target/debug/build/libsql-sqlite3-parser-e0b30187e4067b66/build_script_build-e0b30187e4067b66.build_script_build.552d44bf2bc0c1bf-ACCEPT b5ae476e1c7/buil/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/rustc b5ae476e1c7/buil--crate-name b5ae476e1c7/builhtml_escape b5ae476e1c7/buil--edition=2021 rget�� parser-1225c8268--error-format=json f9e3b0779d23d1a.--json=diagnostic-rendered-ansi,artifacts,future-incompat -3567cd5d18ad7f4--crate-type 57952ce4.rlib eebb7a36cbc53.rl/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/rustc 9a7843b6337fc5.r-vV 5a31f5301cd.rlibembed-bitcode=no (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from glguida January 3, 2026 14:58
@glguida
glguida marked this pull request as ready for review January 3, 2026 15:07
Copilot AI review requested due to automatic review settings January 3, 2026 15:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enables Write-Ahead Logging (WAL) mode in libSQL to improve database performance and concurrency. WAL mode allows multiple readers to access the database while writes are in progress, provides better crash recovery, and generally improves performance for most workloads.

Key Changes:

  • WAL mode is automatically enabled when creating database connections
  • Added comprehensive test coverage to verify WAL mode is properly enabled on file-based databases
  • Added test-only helper method for verifying journal mode

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/vectordb.rs Enables WAL mode in VectorDatabaseConnection::new(), adds test helper method get_journal_mode(), and includes test to verify WAL mode enablement
Cargo.toml Adds tempfile as a dev dependency for testing file-based databases
Cargo.lock Updates lock file to include tempfile dependency and its transitive dependencies

The implementation is well-designed and follows best practices. The code properly documents the behavior with in-memory databases (which cannot use WAL mode), uses appropriate error handling, and includes comprehensive tests. The change is minimal, focused, and backwards-compatible. No issues were identified during the review.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glguida
glguida merged commit f99e869 into master Jan 3, 2026
10 checks passed
@glguida
glguida deleted the copilot/enable-wal-in-libsql branch January 3, 2026 15:17
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.

Enable WAL in libSQL

3 participants