potiuk commented on a change in pull request #5323: [AIRFLOW-1464] Batch update
task_instance state
URL: https://github.com/apache/airflow/pull/5323#discussion_r287287839
##########
File path: airflow/jobs/backfill_job.py
##########
@@ -341,13 +341,13 @@ def _task_instances_for_dag_run(self, dag_run,
session=None):
dag_run.refresh_from_db()
make_transient(dag_run)
- # TODO(edgarRd): AIRFLOW-1464 change to batch query to improve perf
for ti in dag_run.get_task_instances():
# all tasks part of the backfill are scheduled to run
if ti.state == State.NONE:
- ti.set_state(State.SCHEDULED, session=session)
+ ti.set_state(State.SCHEDULED, session=session, commit=False)
if ti.state != State.REMOVED:
tasks_to_run[ti.key] = ti
+ session.commit()
Review comment:
I think it will be safer if you surround it with try/except and perform
rollback in except before re-raising(). Otherwise you might get some partial
back-filling if it fails somewhere between. This would make the whole
back-fill atomic.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services