fix: avoid scheduler registration deadlock

This commit is contained in:
lda
2026-09-09 23:20:56 +07:00 Verified
parent fc95326250
commit 6a87711f89
4 changed files with 113 additions and 20 deletions
+5 -5
View File
@@ -207,7 +207,7 @@ class WorkflowRunApi:
# the gate.
gate = self.resume_slot_gate
if gate is not None:
slot = gate.acquire(run_id, owner_task=asyncio.current_task())
slot = await gate.acquire(run_id, owner_task=asyncio.current_task())
else:
slot = None
slot_held = slot is not None
@@ -226,7 +226,7 @@ class WorkflowRunApi:
# still live is reconciled for this run immediately, so its
# ambiguous failure frees capacity without becoming retryable.
if slot_held and gate is not None:
gate.reconcile_cancelled(run_id)
await gate.reconcile_cancelled(run_id)
raise
except BaseException:
# Pre-persist errors, torn persists, and validation failures:
@@ -235,11 +235,11 @@ class WorkflowRunApi:
# attempt / stopped result already captures the ambiguity for
# recovery to reconcile by attempt identity.
if slot_held and gate is not None:
gate.release(run_id)
await gate.release(run_id)
raise
else:
if slot_held and gate is not None:
gate.release(run_id)
await gate.release(run_id)
return result
async def _resume_scheduled_or_manual(
@@ -352,7 +352,7 @@ class WorkflowRunApi:
# quietly — restart recovery reconciles those instead.
gate = self.resume_slot_gate
if gate is not None:
gate.note_resumed_result(
await gate.note_resumed_result(
run_id,
status_value=run.status.value,
checkpoint_id=next_record.latest_checkpoint_id,