fix(work_assistant): 修复审核任务并发初始化与超时问题
- review_jobs/bid_queue 增加 schema 锁与双重检查初始化 - 调用失败时关闭连接,避免资源泄漏 - review_commentary 复用阶段剩余超时预算,避免误重启 - routes 捕获 SQLite BUSY/LOCKED 并返回 503 重试响应 - submission_advice 精简数据模型与提示语,聚焦用途校验
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import secrets
|
||||
import logging
|
||||
import math
|
||||
import sqlite3
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, Header, HTTPException, Response
|
||||
@@ -52,6 +53,17 @@ class BidValidationRoute(APIRoute):
|
||||
async def handler(request):
|
||||
try:
|
||||
return await original(request)
|
||||
except sqlite3.OperationalError as exc:
|
||||
# A busy checkpoint store is recoverable, not a bad report.
|
||||
# Other SQL errors must remain visible as server faults.
|
||||
code = getattr(exc, 'sqlite_errorcode', 0) & 0xff
|
||||
if code not in {sqlite3.SQLITE_BUSY, sqlite3.SQLITE_LOCKED}:
|
||||
raise
|
||||
logger.warning('review_store_busy path=%s', request.url.path)
|
||||
headers = {'Retry-After': '5', 'X-Review-State': 'review_backoff'}
|
||||
if request.url.path.endswith('/personnel-profile-review'):
|
||||
headers['X-Personnel-Job-Protocol'] = str(PERSONNEL_JOB_PROTOCOL)
|
||||
return JSONResponse(status_code=503, content={'detail': '分析状态存储繁忙,稍后自动重试'}, headers=headers)
|
||||
except RequestValidationError as exc:
|
||||
if not request.url.path.endswith('/bid-writing-step'):
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user