~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor(db): centralize pool_pre_ping and pool_recycle into pool_config.py (#3209)
LearningCircuitedbe5933c798
diff --git a/src/local_deep_research/database/auth_db.py b/src/local_deep_research/database/auth_db.pyindex 0a2764a131..be91853244 100644--- a/src/local_deep_research/database/auth_db.py+++ b/src/local_deep_research/database/auth_db.py@@ -17,6 +17,7 @@ from sqlalchemy.schema import CreateIndex, CreateTablefrom ..config.paths import get_data_directoryfrom .models.auth import User+from .pool_config import POOL_PRE_PING, POOL_RECYCLE_SECONDS# Global cached engine for auth database to prevent file descriptor leaks@@ -77,8 +78,8 @@ def _get_auth_engine() -> Engine:poolclass=QueuePool,pool_size=5,max_overflow=10,- pool_pre_ping=True, # Verify connections before use- pool_recycle=14400, # Recycle connections after 4 h to bound SQLCipher memory/state accumulation+ pool_pre_ping=POOL_PRE_PING,+ pool_recycle=POOL_RECYCLE_SECONDS,echo=False,)_auth_engine_path = auth_db_pathdiff --git a/src/local_deep_research/database/encrypted_db.py b/src/local_deep_research/database/encrypted_db.pyindex 48f5b34c1c..1e54fa1f9e 100644--- a/src/local_deep_research/database/encrypted_db.py+++ b/src/local_deep_research/database/encrypted_db.py@@ -18,6 +18,7 @@ from sqlalchemy.pool import QueuePool, NullPool, StaticPoolfrom ..config.paths import get_data_directory, get_user_database_filenamefrom ..settings.env_registry import get_env_settingfrom .sqlcipher_compat import get_sqlcipher_module+from .pool_config import POOL_PRE_PING, POOL_RECYCLE_SECONDSfrom .sqlcipher_utils import (set_sqlcipher_key,set_sqlcipher_rekey,@@ -66,8 +67,8 @@ class DatabaseManager:return {"pool_size": 10,"max_overflow": 30, # Increase overflow so we don't run out of connections- "pool_pre_ping": True, # Validate connections before use (prevents stale connections)- "pool_recycle": 14400, # Recycle connections after 4 h to bound SQLCipher memory/state accumulation+ "pool_pre_ping": POOL_PRE_PING,+ "pool_recycle": POOL_RECYCLE_SECONDS,}def _is_valid_encryption_key(self, password: str) -> bool:diff --git a/src/local_deep_research/database/pool_config.py b/src/local_deep_research/database/pool_config.pynew file mode 100644index 0000000000..242fde0b44--- /dev/null+++ b/src/local_deep_research/database/pool_config.py@@ -0,0 +1,12 @@+"""Shared SQLAlchemy connection pool configuration constants.++Pool sizing (pool_size, max_overflow) remains per-engine since+different databases have different concurrency profiles.+"""++# Validate connections before checkout (detects stale/broken connections)+POOL_PRE_PING = True++# Recycle connections after 4 hours to release file handles+# in long-running processes+POOL_RECYCLE_SECONDS = 14400diff --git a/tests/database/test_pool_config.py b/tests/database/test_pool_config.pynew file mode 100644index 0000000000..ab30185872--- /dev/null+++ b/tests/database/test_pool_config.py@@ -0,0 +1,30 @@+"""+Test that pool configuration constants have expected values.++These tests ensure consistency across database engines.+If values need to change, update pool_config.py and these tests together.+"""+++class TestPoolConfigConstants:+ """Verify shared pool configuration constants."""++ def test_pool_pre_ping_is_true(self):+ from local_deep_research.database.pool_config import POOL_PRE_PING++ assert POOL_PRE_PING is True++ def test_pool_recycle_seconds_value(self):+ from local_deep_research.database.pool_config import (+ POOL_RECYCLE_SECONDS,+ )++ assert POOL_RECYCLE_SECONDS == 14400++ def test_pool_recycle_is_positive_integer(self):+ from local_deep_research.database.pool_config import (+ POOL_RECYCLE_SECONDS,+ )++ assert isinstance(POOL_RECYCLE_SECONDS, int)+ assert POOL_RECYCLE_SECONDS > 0