hrithiksaini99 opened a new pull request, #76322:
URL: https://github.com/apache/airflow/pull/76322

   Closes #76320.
   
   ## Root cause
   
   `TriggerRunnerSupervisor` keeps every pending cancel in 
`cancelling_triggers` and resends the whole set with each `TriggerStateSync`. 
The runner loop runs about once a second, so `TriggerRunner.cancel_triggers()` 
called `Task.cancel()` again on a trigger whose `on_kill()` was still awaiting. 
That second `CancelledError` aborted `on_kill()` long before `[triggerer] 
on_kill_timeout` (30s), which matches the reported 0.1s-works / 1.5s-aborts 
repro.
   
   ## Change
   
   Record that a cancel was already requested for the trigger and ignore 
repeats. `on_kill()` can now use its full timeout; cleanup and reassignment 
behavior are unchanged.
   
   ## Tests
   
   `test_cancel_triggers_is_idempotent_across_state_syncs` feeds the same 
trigger id through two state syncs and asserts a single `Task.cancel()` with 
the user-action sentinel.
   
   ```
   uv run --project airflow-core pytest 
airflow-core/tests/unit/jobs/test_triggerer_job.py -k "cancel_triggers or 
on_kill"
   7 passed
   ```
   
   `ruff check` and `ruff format --check` pass on both changed files.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to