Skip to content

Commit

Permalink
Avoid sharing session with RenderedTaskInstanceFields write and delete (
Browse files Browse the repository at this point in the history
#9993)

Sharing session with RTIF leads to idle-in-transaction timeout error when DAG serialization is enabled and task running duration exceeds the idle-in-transaction timeout setting of the database.

(cherry picked from commit ffcd060)
  • Loading branch information
22quinn authored and kaxil committed Aug 15, 2020
1 parent e62d3cd commit 21066c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,8 @@ def signal_handler(signum, frame):

self.render_templates(context=context)
if STORE_SERIALIZED_DAGS:
RTIF.write(RTIF(ti=self, render_templates=False), session=session)
RTIF.delete_old_records(self.task_id, self.dag_id, session=session)
RTIF.write(RTIF(ti=self, render_templates=False))
RTIF.delete_old_records(self.task_id, self.dag_id)

task_copy.pre_execute(context=context)

Expand Down

0 comments on commit 21066c2

Please sign in to comment.