1fanwang opened a new issue, #66796:
URL: https://github.com/apache/airflow/issues/66796
### Apache Airflow version
main (3.x)
### What happened?
`SerializedDagModel.get_count()` returns
`session.scalar(select(func.count()).select_from(cls)) or 0`. The `or 0`
collapses the legitimately-impossible None case with the "table is empty" case
(which actually returns 0, not None) — and also masks any transient DB error
that surfaces as None from `session.scalar()`.
In practice the only path that reaches `or 0` is a DB-side failure, and
silently emitting `serialized_dag.count = 0` causes false on-call pages ("all
DAGs disappeared!") while hiding the real problem.
### What you think should happen instead?
Drop the `or 0`. `select(func.count())` on an aggregate is guaranteed to
return an int, so a None return is anomalous and should raise (or log warning +
raise). Callers can opt into try/except as needed.
### Anything else?
This is a 1-line change in the model; one caller in
`dag_processing/manager.py` emits the count to a metric path and should wrap in
try/except after the change.
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
--
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]