You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/06 01:50:16 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #20699: Fix duplicate trigger creation race condition

uranusjr commented on a change in pull request #20699:
URL: https://github.com/apache/airflow/pull/20699#discussion_r779249007



##########
File path: airflow/jobs/triggerer_job.py
##########
@@ -380,10 +380,16 @@ def update_triggers(self, requested_trigger_ids: Set[int]):
         # line's execution, but we consider that safe, since there's a strict
         # add -> remove -> never again lifecycle this function is already
         # handling.
-        current_trigger_ids = set(self.triggers.keys())
+        running_trigger_ids = set(self.triggers.keys())
+        known_trigger_ids = (
+            running_trigger_ids.union({x[0] for x in self.events})
+            .union(self.to_cancel)
+            .union({x[0] for x in self.to_create})
+            .union(self.failed_triggers)
+        )

Review comment:
       ```suggestion
           known_trigger_ids = (
               running_trigger_ids.union(x[0] for x in self.events)
               .union(self.to_cancel)
               .union(x[0] for x in self.to_create)
               .union(self.failed_triggers)
           )
   ```
   
   The thing I always like `union()` `difference()` etc. over `|` `-` etc. is the former does not require the rho to be a set, just any iterable.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org