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 2019/01/15 20:56:39 UTC

[GitHub] ashb commented on a change in pull request #4528: [AIRFLOW XXX] adding exception catch to trigger_dag api

ashb commented on a change in pull request #4528: [AIRFLOW XXX] adding exception catch to trigger_dag api
URL: https://github.com/apache/airflow/pull/4528#discussion_r248059306
 
 

 ##########
 File path: airflow/api/common/experimental/trigger_dag.py
 ##########
 @@ -57,6 +58,12 @@ def _trigger_dag(
             dag_id
         ))
 
+    if UniqueExecutionDate and dag_run.find(dag_id=dag_id, execution_date=execution_date):
+        raise ExecutionDateAlreadyExists("Execution date {} already exists for dag id {}".format(
+            execution_date,
+            dag_id
+        ))
 
 Review comment:
   This sort of pattern (of check for unique then insert) is prone to race conditions and isn't perfect. The only sure fire way to guarantee uniqueness is to have a DB constraint and handle the constraint violation that the DB will raise.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services