fix(stock-lab): screener DB connection WAL 모드 + busy_timeout 30s
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 흐름 안정화.
This commit is contained in:
@@ -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 ----------
|
||||
|
||||
Reference in New Issue
Block a user