fix(automation): 修复账号供给补货队列饥饿

- 拆分订单补货和通用供给水位,供给保留独立 pending 配额
- 每批固定供给槽位,避免订单补货占满队列
- 只补覆盖/可兑换缺口,可分配缺口不再无效入队
- 重登工作超过 24h 自动转人工,清理待处理积压
- 补货阻塞告警和队列诊断信息
- 增加供给公平调度/过期清理回归测试
This commit is contained in:
yml
2026-11-24 13:38:19 +08:00
parent 5b6d146f93
commit eda6115ca3
10 changed files with 462 additions and 42 deletions
@@ -9,6 +9,7 @@ from sqlalchemy.orm import Session
from ....models import AccountWorkItem, AutomationJob
from ...account_sync_runner import ACCOUNT_SYNC_WORK_TYPES, run_account_sync_queue
from ...account_work_queue import expire_stale_login_work
JOB_KEY = "account_sync_queue"
@@ -31,12 +32,22 @@ def run_account_sync_queue_job(
db: Session,
job: AutomationJob,
) -> dict[str, Any]:
moment = datetime.now(UTC)
expired = expire_stale_login_work(db, now=moment)
if expired:
db.commit()
result = run_account_sync_queue(
db,
batch_size=max(1, int(job.batch_size or 20)),
)
if result.get("scanned"):
result["remaining"] = count_pending_work(db)
if expired:
result["expired_login"] = expired
result["message"] = (
f"{result.get('message') or '账号同步完成'},"
f"过期重登转人工 {expired} 条"
)
return result