Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(db): tighten WAL autocheckpoint default 1000 → 250 frames (#3735)

LearningCircuit3fe85e3e7564
diff --git a/src/local_deep_research/database/sqlcipher_utils.py b/src/local_deep_research/database/sqlcipher_utils.py
index 56abec62bf..1a3200f0b7 100644
--- a/src/local_deep_research/database/sqlcipher_utils.py
+++ b/src/local_deep_research/database/sqlcipher_utils.py
@@ -468,6 +468,14 @@ def apply_performance_pragmas(cursor_or_conn: Any) -> None:
sync_mode = get_env_setting("db_config.synchronous", "NORMAL")
cursor_or_conn.execute(f"PRAGMA synchronous = {sync_mode}")
+ # WAL autocheckpoint frame threshold. SQLite's default of 1000 frames
+ # paired with our 16 KB page size means the WAL can grow to ~16 MB
+ # before SQLite triggers a PASSIVE checkpoint at commit. Lowering the
+ # threshold bounds the WAL high-water-mark on disk for users who never
+ # log out (the explicit TRUNCATE checkpoint runs on dispose, not here).
+ wal_autocheckpoint = get_env_setting("db_config.wal_autocheckpoint", 250)
+ cursor_or_conn.execute(f"PRAGMA wal_autocheckpoint = {wal_autocheckpoint}")
+
def verify_sqlcipher_connection(cursor_or_conn: Any) -> bool:
"""
diff --git a/src/local_deep_research/settings/env_definitions/db_config.py b/src/local_deep_research/settings/env_definitions/db_config.py
index 3792b42b35..fd3b8eb656 100644
--- a/src/local_deep_research/settings/env_definitions/db_config.py
+++ b/src/local_deep_research/settings/env_definitions/db_config.py
@@ -50,6 +50,13 @@ DB_CONFIG_SETTINGS = [
case_sensitive=False,
deprecated_env_var="LDR_DB_SYNCHRONOUS",
),
+ IntegerSetting(
+ key="db_config.wal_autocheckpoint",
+ description="WAL frames threshold for automatic PASSIVE checkpoint at commit. Lower = smaller WAL high-water-mark, faster recovery on open, slightly more frequent fsyncs.",
+ min_value=10,
+ max_value=10000,
+ default=250,
+ ),
# Storage settings
IntegerSetting(
key="db_config.page_size",