You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2024/08/06 17:08:08 UTC
(airflow) branch main updated: Don't reserialize DAG if no revision's applied (#41207)
This is an automated email from the ASF dual-hosted git repository.
potiuk 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 7fa80f9b64 Don't reserialize DAG if no revision's applied (#41207)
7fa80f9b64 is described below
commit 7fa80f9b64d8c97fc9709aa49a8c3b7d51f16ec5
Author: Tzu-ping Chung <ur...@gmail.com>
AuthorDate: Wed Aug 7 01:08:01 2024 +0800
Don't reserialize DAG if no revision's applied (#41207)
* Don't reserialize DAG if no revision's applied
This saves some resource and helps avoid issues in dynamic DAG
generation from the user.
* Move more things into the lock
---
airflow/utils/db.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/airflow/utils/db.py b/airflow/utils/db.py
index 97d78ab26a..e43aa291c1 100644
--- a/airflow/utils/db.py
+++ b/airflow/utils/db.py
@@ -1665,9 +1665,12 @@ def upgradedb(
# New DB; initialize and exit
initdb(session=session, load_connections=False)
return
+
with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):
import sqlalchemy.pool
+ previous_revision = _get_current_revision(session=session)
+
log.info("Creating tables")
val = os.environ.get("AIRFLOW__DATABASE__SQL_ALCHEMY_MAX_SIZE")
try:
@@ -1683,10 +1686,12 @@ def upgradedb(
os.environ["AIRFLOW__DATABASE__SQL_ALCHEMY_MAX_SIZE"] = val
settings.reconfigure_orm()
- if reserialize_dags:
- _reserialize_dags(session=session)
- add_default_pool_if_not_exists(session=session)
- synchronize_log_template(session=session)
+ current_revision = _get_current_revision(session=session)
+
+ if reserialize_dags and current_revision != previous_revision:
+ _reserialize_dags(session=session)
+ add_default_pool_if_not_exists(session=session)
+ synchronize_log_template(session=session)
@provide_session