From db4322006de2d892ce15a635e50c1f3b03d705d6 Mon Sep 17 00:00:00 2001 From: gahusb Date: Wed, 13 May 2026 16:50:25 +0900 Subject: [PATCH] =?UTF-8?q?fix(stock-lab):=20screener=20DB=20connection=20?= =?UTF-8?q?WAL=20=EB=AA=A8=EB=93=9C=20+=20busy=5Ftimeout=2030s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit snapshot/refresh 직후 /run mode=auto가 'database is locked'으로 500 실패하던 증상 fix. SQLite 기본 rollback journal 모드 + busy_timeout=0 조합에서 long write transaction과 read가 겹치면 즉시 OperationalError. PRAGMA journal_mode=WAL: reader가 writer를 block 안 함 PRAGMA busy_timeout=30000: 30초 대기 후 timeout (즉시 실패 X) sqlite3.connect timeout=30: connection 획득 자체에도 대기 적용 agent-office 자동 잡 16:30 KST 흐름 안정화. --- stock-lab/app/screener/router.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stock-lab/app/screener/router.py b/stock-lab/app/screener/router.py index aadd10f..bbf6905 100644 --- a/stock-lab/app/screener/router.py +++ b/stock-lab/app/screener/router.py @@ -45,7 +45,12 @@ def _db_path() -> str: def _conn() -> sqlite3.Connection: - return sqlite3.connect(_db_path()) + # WAL 모드 + busy_timeout으로 동시 read/write lock 회피 + # (snapshot/refresh 직후 /run이 SELECT 시 OperationalError 'database is locked' 방지) + conn = sqlite3.connect(_db_path(), timeout=30.0) + conn.execute("PRAGMA journal_mode=WAL") + conn.execute("PRAGMA busy_timeout=30000") + return conn # ---------- /nodes ----------