You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: resolve DuckDB lock conflicts with guard, read-only connections, and degraded mode
Three-part fix for the recurring duckdb.IOException when multiple processes
try to open trader.duckdb in write mode:
1. Lock guard (db.py): _connect_with_lock_guard() distinguishes stale locks
(dead PID → retry 10 s) from live conflicts (alive PID → immediate
RuntimeError with exact `kill <PID>` command). open_db_readonly() added
for processes that only need reads — multiple processes can hold read-only
connections simultaneously without conflicting with the write owner.
2. MCP server degraded mode (mcp/server.py): lifespan() catches lock
RuntimeError and falls back to :memory: context. Analysis tools
(run_analysis, get_regime, get_system_status) keep working; 22 DB-backed
tools return {"success": false, "degraded_mode": true} instead of crashing
the Claude session.
3. FastAPI read-only (api/server.py): all GET endpoints now use
get_portfolio_state_readonly() and get_decision_log_readonly() — the API
server no longer competes with the MCP server for the write lock.
Also adds get_portfolio_state_readonly() (portfolio_state.py) and
get_decision_log_readonly() (decision_log.py) singletons, 12 new tests
in tests/quant_pod/test_db_lock_guard.py (all pass), and updates
packages/quant_pod/README.md with the multi-process connection model.
0 commit comments