Skip to content

fix: set SQLite WAL pragmas before transactions in etl-indexer#315

Merged
jverdicc merged 1 commit intomainfrom
codex/fix-sqlite-wal-mode-transaction-error
Mar 5, 2026
Merged

fix: set SQLite WAL pragmas before transactions in etl-indexer#315
jverdicc merged 1 commit intomainfrom
codex/fix-sqlite-wal-mode-transaction-error

Conversation

@jverdicc
Copy link
Owner

@jverdicc jverdicc commented Mar 5, 2026

Motivation

  • Tests were failing with SQLite errors because PRAGMA journal_mode=WAL was being executed inside an active transaction, which SQLite disallows.
  • The intent is to ensure WAL and related safety pragmas are applied on the raw connection before any transaction begins so schema DDL and migrations run without hitting journal/safety mode constraints.

Description

  • Removed PRAGMA calls from apply_schema so the schema DDL can run inside transactions without attempting to change journal/safety mode.
  • Added a new helper apply_connection_pragmas(conn: &Connection) that runs PRAGMA journal_mode=WAL;, PRAGMA synchronous=FULL;, and PRAGMA foreign_keys=ON; on the opened connection.
  • Call apply_connection_pragmas immediately after Connection::open(...) in both migrate_schema and build_index, before conn.transaction() is created.
  • Drop the opened Connection (drop(conn)) after committing the transaction in build_index so WAL-backed changes are flushed before renaming the temporary DB file.

Testing

  • Ran the crate tests with cargo test -p evidenceos-etl-indexer and the previously failing test tests::creates_expected_indexes_and_query_results now passes (all crate tests passed).
  • Ran formatting and lints with cargo fmt --all && cargo fmt --check and cargo clippy --workspace --all-targets -- -D warnings, both succeeded with no errors.
  • Ran full workspace tests with cargo test --workspace and observed no failing tests (FINAL:0).

Codex Task

@jverdicc jverdicc merged commit c01f966 into main Mar 5, 2026
6 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant