perf(douyu): 拆分支付轮询并扩展查询并发
This commit is contained in:
@@ -469,17 +469,25 @@ def cleanup_orphan_douyu_tasks(
|
||||
query = query.filter(~DouyuTask.batch_id.in_(list(active_batch_ids)))
|
||||
|
||||
now = datetime.now(UTC)
|
||||
# Scan waits are durable. A restarted scheduler can resume them from the
|
||||
# database, so startup cleanup must not turn them into stopped tasks.
|
||||
query = query.filter(
|
||||
or_(
|
||||
DouyuTask.task_type != "get_bind_qr",
|
||||
DouyuTask.queue_lane != "binding_poll",
|
||||
DouyuTask.next_run_at.is_(None),
|
||||
DouyuTask.run_deadline_at.is_(None),
|
||||
DouyuTask.run_deadline_at <= now,
|
||||
)
|
||||
# Scan and payment waits are durable. A restarted scheduler can resume them
|
||||
# from the database, so startup cleanup must not stop unexpired rows.
|
||||
durable_binding = and_(
|
||||
DouyuTask.task_type == "get_bind_qr",
|
||||
DouyuTask.queue_lane == "binding_poll",
|
||||
DouyuTask.next_run_at.isnot(None),
|
||||
DouyuTask.run_deadline_at.isnot(None),
|
||||
DouyuTask.run_deadline_at > now,
|
||||
)
|
||||
durable_payment = and_(
|
||||
DouyuTask.task_type.in_(
|
||||
{"create_elite_qr", "create_esports_qr", "create_gold_qr"}
|
||||
),
|
||||
DouyuTask.queue_lane == "payment_poll",
|
||||
DouyuTask.next_run_at.isnot(None),
|
||||
DouyuTask.run_deadline_at.isnot(None),
|
||||
DouyuTask.run_deadline_at > now,
|
||||
)
|
||||
query = query.filter(~or_(durable_binding, durable_payment))
|
||||
|
||||
tasks = query.all()
|
||||
if not tasks:
|
||||
|
||||
Reference in New Issue
Block a user