RyukR1 commented on code in PR #77465:
URL: https://github.com/apache/airflow/pull/77465#discussion_r4738845636


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -1475,15 +1475,24 @@ def update_triggers(self, requested_trigger_ids: 
set[int]):
             self.creating_triggers.extend(workloads_to_create)
 
         if cancel_trigger_ids:
-            # Only the DB tells the two cases apart: a gone row means the task 
left the
-            # deferred state (user action), a surviving row means 
assign_unassigned handed
-            # the trigger to a triggerer that is now polling the remote work.
+            # Only the DB tells the cases apart: a gone row means the task 
left the
+            # deferred state (user action), a surviving row with an owner means
+            # assign_unassigned handed the trigger to another triggerer, and a 
surviving
+            # row without an owner means it was paused or unassigned.
             assignments = self.fetch_trigger_assignments(cancel_trigger_ids)
-            if assignments:
+            reassigned = {tid: owner for tid, owner in assignments.items() if 
owner is not None}
+            unassigned = [tid for tid, owner in assignments.items() if owner 
is None]
+            if reassigned:
                 log.info(
                     "Triggers were reassigned to another triggerer, releasing 
them without on_kill",
-                    new_owners=assignments,
+                    new_owners=reassigned,
+                )
+            if unassigned:
+                log.info(
+                    "Triggers were paused or unassigned, releasing them 
without on_kill",
+                    triggers=unassigned,
                 )
+            if assignments:
                 self.releasing_triggers.update(assignments)

Review Comment:
   You're completely right — previously both reassigned triggers and 
unassigned/paused triggers were funneled into `to_release` using 
`_REASSIGNED_CANCEL_MSG`, which caused the runner to log the misleading 
reassignment message.
   
   To fix this cleanly:
   1. Introduced a dedicated cancellation message `_PAUSED_CANCEL_MSG = 
"__airflow_paused__"`.
   2. Added `to_pause: set[int]` to `TriggerStateSync` and tracked 
`pausing_triggers` in `TriggerRunnerSupervisor`.
   3. In `TriggerRunner.cancel_triggers`, drained `self.to_pause` tasks with 
`_PAUSED_CANCEL_MSG`.
   4. In `run_trigger`, caught `_PAUSED_CANCEL_MSG` specifically and logged:
      `"Trigger paused or unassigned, dropping it without on_kill"`
   
   This ensures paused/unassigned watchers log the pause action explicitly in 
both triggerer stdout and the watcher's task log without mentioning 
reassignment.



-- 
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