This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 941c83e1a9 listener: move success hook to after SQLAlchemy commit 
(#32988)
941c83e1a9 is described below

commit 941c83e1a9ec7e70fbe77b3fe7574195c8e7fcd9
Author: Maciej Obuchowski <[email protected]>
AuthorDate: Tue Aug 1 09:04:03 2023 +0200

    listener: move success hook to after SQLAlchemy commit (#32988)
    
    Signed-off-by: Maciej Obuchowski <[email protected]>
---
 airflow/models/taskinstance.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index c31e2d8c15..37d5da21d0 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -1583,11 +1583,13 @@ class TaskInstance(Base, LoggingMixin):
             session.merge(self).task = self.task
             if self.state == TaskInstanceState.SUCCESS:
                 self._register_dataset_changes(session=session)
+
+            session.commit()
+            if self.state == TaskInstanceState.SUCCESS:
                 get_listener_manager().hook.on_task_instance_success(
                     previous_state=TaskInstanceState.RUNNING, 
task_instance=self, session=session
                 )
 
-            session.commit()
         return None
 
     def _register_dataset_changes(self, *, session: Session) -> None:

Reply via email to