Skip to content

[BUG] Database Operations Not Atomic #155

@olddev94

Description

@olddev94

Project

vgrep

Description

Database insert operations for files and chunks are not wrapped in transactions. If the process crashes or is interrupted between inserting a file and its chunks, the database will be left in an inconsistent state with orphan records.

Error Message

No error - silent data inconsistency.

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 indexing a large directory
  2. Kill the process (Ctrl+C, SIGKILL, power failure) during indexing
  3. The database may have:
    • Files without chunks (orphan files)
    • Or if using INSERT OR REPLACE, partial re-indexing could lose data

Expected Behavior

  1. Use transactions for multi-step operations
  2. Either all chunks for a file are inserted, or none
  3. Database remains consistent after any crash

Actual Behavior

  1. Each INSERT is auto-committed immediately
  2. Crash can leave partial data
  3. Orphan files or missing chunks possible

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvalidValid issuevgrep

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions