Skip to content

Commit 40fccd0

Browse files
authored
fix(peewee): enable WAL journal mode for SQLite (#132)
* fix(peewee): enable WAL journal mode for SQLite PeeweeStorage was using SQLite's default DELETE journal mode, while SqliteStorage already had WAL enabled. Without WAL, concurrent read/write access from threaded Flask causes frequent "database is locked" errors, leading to 500 responses and watcher retry storms. * fix: remove unnecessary wal_autocheckpoint override SQLite's default of 1000 pages is fine; setting 100 would cause more frequent checkpointing and unnecessary IO.
1 parent d628a9a commit 40fccd0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

aw_datastore/storages/peewee.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ def __init__(self, testing: bool = True, filepath: Optional[str] = None) -> None
146146
)
147147
filepath = os.path.join(data_dir, filename)
148148
self.db = _db
149-
self.db.init(filepath)
149+
self.db.init(filepath, pragmas={
150+
"journal_mode": "wal",
151+
})
150152
logger.info(f"Using database file: {filepath}")
151153
self.db.connect()
152154

0 commit comments

Comments
 (0)