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

Revert "Fix future DagRun rarely triggered by race conditions when max_active_runs reached its upper limit. (#31414)" #37596

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from sqlalchemy import and_, delete, func, not_, or_, select, text, update
from sqlalchemy.exc import OperationalError
from sqlalchemy.orm import joinedload, lazyload, load_only, make_transient, selectinload
from sqlalchemy.orm import lazyload, load_only, make_transient, selectinload
from sqlalchemy.sql import expression

from airflow import settings
Expand Down Expand Up @@ -1418,22 +1418,11 @@ def _schedule_dag_run(
callback: DagCallbackRequest | None = None

dag = dag_run.dag = self.dagbag.get_dag(dag_run.dag_id, session=session)
# Adopt row locking to account for inconsistencies when next_dagrun_create_after = None
query = (
select(DagModel).where(DagModel.dag_id == dag_run.dag_id).options(joinedload(DagModel.parent_dag))
)
dag_model = session.scalars(
with_row_locks(query, of=DagModel, session=session, skip_locked=True)
).one_or_none()
dag_model = DM.get_dagmodel(dag_run.dag_id, session)

if not dag:
if not dag or not dag_model:
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 the DAG record was locked", dag_run.dag_id
)
return callback

if (
dag_run.start_date
Expand Down