Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix future DagRun rarely triggered by race conditions when max_active_runs reached its upper limit. #31414

Merged
merged 8 commits into from Aug 8, 2023
6 changes: 5 additions & 1 deletion airflow/jobs/scheduler_job_runner.py
Expand Up @@ -1374,7 +1374,6 @@ def _schedule_dag_run(
callback: DagCallbackRequest | None = None

dag = dag_run.dag = self.dagbag.get_dag(dag_run.dag_id, session=session)
dag_model = DM.get_dagmodel(dag_run.dag_id, session)
# Adopt row locking to account for inconsistencies when next_dagrun_create_after = None
query = (
session.query(DagModel)
Expand All @@ -1389,6 +1388,11 @@ def _schedule_dag_run(
self.log.error("Couldn't find DAG %s in DAG bag or database!", dag_run.dag_id)
return callback
if not dag_model:
self.log.info(
"DAG %s scheduling was skipped, "
"probably because DAG was None due to skip_locked in with_row_locks",
uranusjr marked this conversation as resolved.
Show resolved Hide resolved
dag_run.dag_id,
)
return callback

if (
Expand Down