fix: enable SQLite WAL mode to prevent locks (#493)#509
Merged
aaronbrethorst merged 1 commit intoOneBusAway:mainfrom Mar 1, 2026
Merged
Conversation
aaronbrethorst
approved these changes
Mar 1, 2026
Member
aaronbrethorst
left a comment
There was a problem hiding this comment.
Hey Aditya -- Clean and surgical fix. The configureConnectionPool comments have been referencing WAL mode since the connection pool was set up, but the PRAGMA was never actually applied. This PR closes that gap with minimal, correct code and appropriate test coverage.
No Issues Found
The change is correct:
PRAGMA journal_mode=WALis a database-level persistent setting for file-based databases, so it correctly applies across all pooled connections.- For
:memory:databases, SQLite silently falls back tomemoryjournal mode (no error), which is the right behavior since the connection pool is already limited to 1 for in-memory databases. - The test assertions verify both cases:
"wal"for file databases,"memory"for in-memory databases.
Verification
- Tests: all pass
- Lint: 0 issues
- Single commit: clean
Strengths
- Minimal and focused: 2 lines of production code, exactly what was needed.
- Both cases tested: File-based databases get WAL mode verified, in-memory databases get the fallback behavior verified.
- Accurate comments: The inline comment correctly describes what WAL mode provides.
Looks good -- merge it!
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.
Description
This PR addresses issue #493 by explicitly enabling Write-Ahead Logging (WAL) for SQLite databases.
Previously,
WALmode was referenced in the connection pool comments but was never actually applied in the database configuration. Without WAL mode, SQLite falls back to the default rollback journal where readers block writers and writers block readers. WithMaxOpenConnsset to 25 for file-based databases, this would inevitably lead todatabase is lockederrors under concurrent production load.Changes Made
gtfsdb/helpers.go: AddedPRAGMA journal_mode=WALto theconfigureSQLitePerformancefunction to allow concurrent readers and a single writer.gtfsdb/sqlite_performance_test.go:TestFileDatabaseConnectionPoolto verify thatwalmode is properly enabled for file-based databases.TestSQLitePerformancePragmasAppliedto verify that:memory:databases safely fall back tomemoryjournal mode (as SQLite does not support WAL in-memory).Related Issues
Closes #493
Checklist