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 2018/12/10 18:34:52 UTC
[GitHub] Fokko commented on a change in pull request #4298: [AIRFLOW-3478]
Make sure that the session is closed
Fokko commented on a change in pull request #4298: [AIRFLOW-3478] Make sure that the session is closed
URL: https://github.com/apache/incubator-airflow/pull/4298#discussion_r240329624
##########
File path: airflow/api/common/experimental/mark_tasks.py
##########
@@ -180,18 +180,15 @@ def set_state(task, execution_date, upstream=False, downstream=False,
tis_altered += qry_sub_dag.with_for_update().all()
for ti in tis_altered:
ti.state = state
- session.commit()
else:
tis_altered = qry_dag.all()
if len(sub_dag_ids) > 0:
tis_altered += qry_sub_dag.all()
- session.expunge_all()
Review comment:
I had to dig deeper into this. By default, [the objects are cleaned up](https://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.commit): By default, the `Session` also expires all database loaded state on all ORM-managed attributes after transaction commit. This so that subsequent operations load the most recent data from the database. This behavior can be disabled using the `expire_on_commit=False` option to sessionmaker or the `Session`constructor.
But I've noticed that we explicitly set the `expire_on_commit=False`.
https://github.com/apache/incubator-airflow/blob/ded25e16c1fb912019d3d0e5d47d020dccaa54b7/airflow/settings.py#L198
In this case this change would indeed change behaviour. Maybe remove the `expire_on_commit ` to make it simpeler?
----------------------------------------------------------------
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