Skip to content

[BUG] Database Doesn't Enable WAL Mode #132

@olddev94

Description

@olddev94

Project

vgrep

Description

The SQLite database in src/core/db.rs is opened without enabling WAL (Write-Ahead Logging) mode. This can cause concurrency issues when multiple processes access the database simultaneously (e.g., watcher + search) and reduces write performance.

Error Message

Error: database is locked

or

SQLITE_BUSY

Debug Logs

System Information

- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+

Screenshots

No response

Steps to Reproduce

  1. Start the watcher in one terminal: vgrep watch
  2. Run searches in another terminal: vgrep search "query"
  3. Modify files while searching
  4. Observe occasional "database is locked" errors

Expected Behavior

The database should:

  1. Enable WAL mode for better concurrency
  2. Set a busy timeout to handle lock contention gracefully
  3. Potentially set synchronous mode for performance

Actual Behavior

  1. Uses default DELETE journal mode
  2. No busy timeout (immediate SQLITE_BUSY on contention)
  3. Writers block readers and vice versa
  4. Suboptimal write performance

Additional Context

WAL mode benefits:

  • Readers don't block writers
  • Writers don't block readers
  • Better write performance (commits can overlap)
  • Crash recovery is more robust

The issue manifests when:

  • File watcher is running while user searches
  • Server handles multiple simultaneous requests
  • Index operation runs while search occurs

Without WAL mode, SQLite uses rollback journal which requires exclusive locks for writes, causing blocking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEinvalidThis doesn't seem rightvgrep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions