ashb commented on code in PR #51134:
URL: https://github.com/apache/airflow/pull/51134#discussion_r2235857313
##########
airflow-core/src/airflow/models/serialized_dag.py:
##########
@@ -401,15 +402,29 @@ def write_dag(
# If Yes, does nothing
# If No or the DAG does not exists, updates / writes Serialized DAG to
DB
if min_update_interval is not None:
- if session.scalar(
- select(literal(True))
- .where(
- cls.dag_id == dag.dag_id,
- (timezone.utcnow() -
timedelta(seconds=min_update_interval)) < cls.last_updated,
+ try:
+ do_nothing = session.scalar(
+ select(literal(True))
+ .where(
+ cls.dag_id == dag.dag_id,
+ (timezone.utcnow() -
timedelta(seconds=min_update_interval)) < cls.last_updated,
+ )
+ .select_from(cls)
+ .with_for_update(nowait=True, skip_locked=True)
)
- .select_from(cls)
- ):
- return False
+ if do_nothing:
+ return False
+ except OperationalError as e:
+ if (
+ hasattr(e, "orig") and hasattr(e.orig, "pgcode") and
e.orig.pgcode == "55P03"
+ ): # Postgres error code for "could not obtain lock on row in
relation [table_name]"
+ log.warning(
+ "Another Scheduler is already reparsing dag %s.
Skipping reparse request. Details: %s",
+ dag.dag_id,
Review Comment:
a) This is not the scheduler, but the dag processors, and in Airflow 3 the
dag parser is separate to the scheduler.
b) This at warning is likely too noisy, and not actually anything to worry
about but a natural fact of running multiple dag parsers, This should be debug,
or maybe info, but no higher
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]