Skip to content

Commit 584aba2

Browse files
committed
Set journal size limit to 10 MB for SQLite connections to prevent unbounded WAL growth
1 parent ea5585a commit 584aba2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

server/database.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def open(self):
7575
# When temp_store is MEMORY (2) temporary tables and indices
7676
# are kept as if they were in pure in-memory databases.
7777
self.sql_connection.execute("PRAGMA temp_store=MEMORY;")
78+
# WAL size limit: cap at 10 MB. When approached, SQLite auto-checkpoints
79+
# even if other connections are active. Prevents unbounded WAL growth
80+
# on systems with multiple long-lived processes (backend, nginx, PHP-FPM).
81+
self.sql_connection.execute("PRAGMA journal_size_limit=10000000;")
7882

7983
self.sql_connection.text_factory = str
8084
self.sql_connection.row_factory = sqlite3.Row
@@ -330,5 +334,6 @@ def get_temp_db_connection():
330334
conn = sqlite3.connect(fullDbPath, timeout=5, isolation_level=None)
331335
conn.execute("PRAGMA journal_mode=WAL;")
332336
conn.execute("PRAGMA busy_timeout=5000;") # 5s wait before giving up
337+
conn.execute("PRAGMA journal_size_limit=10000000;") # 10 MB WAL cap with auto-checkpoint
333338
conn.row_factory = sqlite3.Row
334339
return conn

0 commit comments

Comments
 (0)