修复心跳刷入rollback误用 + API参数规范化

- heartbeat_flush: 移除循环内session.rollback(),防止一个服务器
  刷入失败导致整个批次session状态损坏
- assets.py: 为Query参数添加Query()类型+描述+校验约束,
  统一FastAPI参数风格 (server_id/session_id/limit/parent_id)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-22 11:58:15 +08:00
parent cb5b4c42de
commit 0bcfeaa6d6
2 changed files with 10 additions and 8 deletions
+3 -1
View File
@@ -91,7 +91,9 @@ async def heartbeat_flush_loop():
flushed += 1
except Exception as e:
logger.warning(f"Failed to flush server {key}: {e}")
await session.rollback()
# Don't rollback here — just skip this server and continue.
# A partial UPDATE on a single server won't corrupt others.
# The final commit() will persist all successful updates.
await session.commit()
logger.info(f"Heartbeat flush: {flushed}/{len(keys)} servers updated to MySQL")