~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
chore(observability): surface WAL-dispose failures + document LDR_APP_DEBUG sensitivity (#4042)
LearningCircuitf664221ce405
diff --git a/changelog.d/+observability-wal-dispose-and-debug-doc.misc.md b/changelog.d/+observability-wal-dispose-and-debug-doc.misc.mdnew file mode 100644index 0000000000..54584f1acf--- /dev/null+++ b/changelog.d/+observability-wal-dispose-and-debug-doc.misc.md@@ -0,0 +1 @@+Pool-dispose failures in the periodic WAL/SHM handle-release workaround (ADR-0004) now log at ``WARNING`` instead of ``DEBUG`` so silent drift becomes visible. Documented in ``docs/CONFIGURATION.md`` that ``LDR_APP_DEBUG=true`` also enables Loguru ``diagnose=True``, which can materialise sensitive locals into exception traces — do not enable in production.diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.mdindex ac806f61ae..934fa8cdee 100644--- a/docs/CONFIGURATION.md+++ b/docs/CONFIGURATION.md@@ -63,7 +63,7 @@ They are not available in the Web UI because they are needed to start the applic| Key | Environment Variable | Default Value | Description | Type ||-----|----------------------|---------------|-------------|------|| `app.allow_registrations` | `LDR_APP_ALLOW_REGISTRATIONS` | `true` | Allow new user registrations through the web interface. Configured via LDR_APP_ALLOW_REGISTRATIONS environment variable. Set to 'false' to disable on public-facing deployments. Enabled by default so initial account creation works out of the box. Requires server restart. | APP |-| `app.debug` | `LDR_APP_DEBUG` | `false` | Produces more informative errors when something goes wrong, but may expose sensitive data. Configured via LDR_APP_DEBUG environment variable. Requires server restart. | APP |+| `app.debug` | `LDR_APP_DEBUG` | `false` | Produces more informative errors when something goes wrong, but may expose sensitive data. Also enables Loguru `diagnose=True` on every sink, which materializes local-variable values into exception traces — these traces can include credentials, decrypted user content, and other sensitive locals captured at the failure site. Do NOT enable in production. Configured via LDR_APP_DEBUG environment variable. Requires server restart. | APP || `app.enable_file_logging` | `LDR_APP_ENABLE_FILE_LOGGING` | `false` | Enable logging to files (WARNING: Log files are unencrypted and may contain sensitive data) | APP || `app.enable_notifications` | `LDR_APP_ENABLE_NOTIFICATIONS` | `true` | Enable browser push notifications to alert you when research completes or encounters errors. Requires browser permission to display notifications. | APP || `app.enable_web` | `LDR_APP_ENABLE_WEB` | `true` | Enable the web interface. When disabled, the application runs in CLI-only mode. Requires server restart to take effect. | APP |diff --git a/src/local_deep_research/web/auth/connection_cleanup.py b/src/local_deep_research/web/auth/connection_cleanup.pyindex 29aa48cb9e..e97d66746a 100644--- a/src/local_deep_research/web/auth/connection_cleanup.py+++ b/src/local_deep_research/web/auth/connection_cleanup.py@@ -162,8 +162,25 @@ def cleanup_idle_connections(session_manager, db_manager):db_manager._checkpoint_wal(engine, f"for {username}")engine.dispose()disposed += 1- except Exception:- logger.debug(f"Error disposing engine for {username}")+ except Exception as exc:+ # Surface the failure. Pre-fix this was logger.debug,+ # which hid the symptom — if WAL checkpoint or pool+ # dispose repeatedly fails (disk pressure, lock+ # starvation, etc.) the WAL file silently grows on+ # disk and pooled connections leak. The 30-min+ # periodic-dispose workaround for ADR-0004's WAL/SHM+ # handle leak depends on this loop succeeding.+ #+ # Only the exception's TYPE NAME is logged, matching+ # the codebase's `_report_silent_exception` pattern+ # (utilities/log_utils.py:146-194). The exception+ # value itself can carry sensitive locals (DB paths,+ # query fragments, etc.) and our sensitive-logging+ # hook flags any `f"...{exc}"` interpolation.+ exc_type = type(exc).__name__+ logger.warning(+ f"Error disposing engine for {username}: {exc_type}"+ )if disposed:logger.info(f"Pool dispose: reset {disposed} engine(s) to release "diff --git a/tests/web/auth/test_connection_cleanup_fallback.py b/tests/web/auth/test_connection_cleanup_fallback.pyindex 276d4d3f1b..dca9189e74 100644--- a/tests/web/auth/test_connection_cleanup_fallback.py+++ b/tests/web/auth/test_connection_cleanup_fallback.py@@ -186,6 +186,45 @@ class TestPeriodicPoolDispose:# The timer was updated so a rapid second call would NOT re-dispose.assert cc_module._last_dispose_time > 0+ @patch(+ "local_deep_research.scheduler.background.get_background_job_scheduler",+ )+ @patch(+ "local_deep_research.web.auth.connection_cleanup.get_usernames_with_active_research",+ return_value=set(),+ )+ def test_dispose_failures_surface_as_warnings(+ self, _mock_research, _mock_sched, sm, db+ ):+ """The pool-dispose workaround for ADR-0004's WAL/SHM handle leak+ depends on this loop succeeding. Pre-fix dispose() failures were+ logged at DEBUG, which hid silent drift if checkpoint/dispose+ repeatedly failed (disk pressure, lock starvation). Failures must+ surface at WARNING so an operator sees them, but only the+ exception TYPE NAME (no value) — the value can carry sensitive+ locals.+ """+ bad_engine = MagicMock()+ bad_engine.dispose.side_effect = RuntimeError(+ "potentially-sensitive details"+ )+ db.connections = {"alice": bad_engine}++ with patch.object(cc_module.logger, "warning") as mock_warn:+ cleanup_idle_connections(sm, db)++ # The failure path emitted a warning that names the user and the+ # exception TYPE, not the exception value.+ warning_calls = [str(call) for call in mock_warn.call_args_list]+ assert any(+ "alice" in call and "RuntimeError" in call for call in warning_calls+ )+ # The exception's message text must not appear in any warning —+ # only the type name is logged.+ assert not any(+ "potentially-sensitive details" in call for call in warning_calls+ )+@patch("local_deep_research.scheduler.background.get_background_job_scheduler",)