fix(douyu): 修复斗鱼链路 P0/P1 隐患并增强 P2 运维队列可观测性
This commit is contained in:
@@ -527,8 +527,7 @@ def _find_reusable_same_role_target(
|
||||
PlatformFulfillmentTask.id != int(task.id),
|
||||
PlatformFulfillmentTask.account_id.isnot(None),
|
||||
PlatformFulfillmentTask.execution_status != "cancelled",
|
||||
func.lower(func.trim(PlatformFulfillmentTask.customer_role_name))
|
||||
== role.casefold(),
|
||||
PlatformFulfillmentTask.customer_role_norm == role.strip().casefold(),
|
||||
)
|
||||
.order_by(
|
||||
case((PlatformFulfillmentTask.lease_id.isnot(None), 0), else_=1),
|
||||
|
||||
@@ -7,7 +7,7 @@ from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import case, func
|
||||
from sqlalchemy import case
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import Session
|
||||
from starlette.concurrency import run_in_threadpool
|
||||
@@ -249,8 +249,8 @@ def _propagate_same_role_binding_to_siblings(
|
||||
PlatformFulfillmentTask.execution_status.notin_(("completed", "cancelled")),
|
||||
PlatformFulfillmentTask.binding_status.in_(ACTIVE_BINDING_STATUSES),
|
||||
PlatformFulfillmentTask.customer_role_name != "",
|
||||
func.lower(func.trim(PlatformFulfillmentTask.customer_role_name))
|
||||
== role_name.casefold(),
|
||||
PlatformFulfillmentTask.customer_role_norm
|
||||
== role_name.strip().casefold(),
|
||||
)
|
||||
.order_by(PlatformFulfillmentTask.id.asc())
|
||||
.with_for_update(skip_locked=True)
|
||||
@@ -2286,6 +2286,10 @@ def verify_task_binding_sync(
|
||||
role = resolve_elite_role(client, config)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
role = {"status": ROLE_ERROR, "errors": [str(exc)], "bind_infos": []}
|
||||
finally:
|
||||
close = getattr(client, "close", None)
|
||||
if callable(close):
|
||||
close()
|
||||
|
||||
bind_infos = [
|
||||
item for item in (role.get("bind_infos") or []) if isinstance(item, dict)
|
||||
|
||||
Reference in New Issue
Block a user