Merge branch 'hugo-shipping-notice' into test
This commit is contained in:
commit
387b3157fe
113 files changed
+6036
-1759
No files matched your search
@@ -792,6 +792,24 @@ def _validate_rpa_callback_round(task: ShippingNotice, payload: dict[str, Any])
|
||||
return None
|
||||
|
||||
|
||||
def _lock_process_gates_for_task(task: ShippingNotice) -> None:
|
||||
"""
|
||||
[锁序约定] 回调写库存候选数据前,先锁该任务活跃 Execution 的全部 Gate 行。
|
||||
|
||||
外部等待轮询(run_inventory_external_wait_poll)的顺序是先锁 Gate 再读候选行;
|
||||
本侧若先写候选、后经 Gate 同步更新 Gate 行,会以相反顺序与轮询形成死锁环,
|
||||
事务被毒化后以 InFailedSqlTransaction 收口且轮询链断裂
|
||||
(2026-09-23 test job 8818:库存 RPA 回调 × external-wait 轮询竞跑)。
|
||||
统一为两侧都先取 Gate 锁:后到方短暂阻塞后串行执行,不再产生错误。
|
||||
"""
|
||||
from app.models import ShippingProcessGate
|
||||
|
||||
execution_id = int(getattr(task, 'active_process_execution_id', 0) or 0)
|
||||
if not execution_id:
|
||||
return
|
||||
ShippingProcessGate.query.filter_by(execution_id=execution_id).with_for_update().all()
|
||||
|
||||
|
||||
def _validate_rpa_callback_gate(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
"""
|
||||
复核 RPA 触发后可能漂移的订单与路由门禁(skipped/failed/success 共用)。
|
||||
@@ -1813,6 +1831,8 @@ def rpa_report_inventory(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
if gate_resp is not None:
|
||||
return gate_resp
|
||||
|
||||
# [锁序约定] 写入前先锁 Gate 行,与 external-wait 轮询串行(见 _lock_process_gates_for_task)。
|
||||
_lock_process_gates_for_task(task)
|
||||
runtime = _save_last_inventory_rpa_runtime(task, payload)
|
||||
callback_status = _normalize_rpa_inventory_result_status(payload)
|
||||
|
||||
@@ -2486,6 +2506,8 @@ def process_rpa_report_inventory_batch(payload: dict[str, Any]) -> dict[str, Any
|
||||
"error": gate_resp.get("message") or "inventory_source_gate_blocked",
|
||||
})
|
||||
continue
|
||||
# [锁序约定] 写入前先锁 Gate 行,与 external-wait 轮询串行(见 _lock_process_gates_for_task)。
|
||||
_lock_process_gates_for_task(task)
|
||||
round_resp = _validate_rpa_callback_round(task, merged_item)
|
||||
if round_resp is not None:
|
||||
round_data = round_resp.get("data") if isinstance(round_resp.get("data"), dict) else {}
|
||||
|
||||
Reference in new issue
Block a user