Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "This Session's transaction has been rolled back" #25532

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion airflow/models/dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,10 @@ def _create_task_instances(
:param session: the session to use
"""
# Fetch the information we need before handling the exception to avoid
# PendingRollbackError due to the session being invalidated on exception
# see https://github.com/apache/superset/pull/530
run_id = self.run_id
try:
if hook_is_noop:
session.bulk_insert_mappings(TI, tasks)
Expand All @@ -1151,7 +1155,7 @@ def _create_task_instances(
self.log.info(
'Hit IntegrityError while creating the TIs for %s- %s',
dag_id,
self.run_id,
run_id,
exc_info=True,
)
self.log.info('Doing session rollback.')
Expand Down