Skip to content

Don't queue runs on DatasetEvent for disabled DAGs#38891

Merged
uranusjr merged 5 commits into
apache:mainfrom
astronomer:do-not-queue-inactive-dags
Apr 19, 2024
Merged

Don't queue runs on DatasetEvent for disabled DAGs#38891
uranusjr merged 5 commits into
apache:mainfrom
astronomer:do-not-queue-inactive-dags

Conversation

@uranusjr

Copy link
Copy Markdown
Member

Maybe fix #38826?

This adds an additional filter on consuming DAG, and only create a DatasetDagRunQueue entry if the DAG is both active (i.e. still exists in a DAG file) and unpaused.

There are still questions unanswered:

  1. Do we consider catchup? The immediate problem here is catchup is not stored on DagModel, and checking it from DAG creates significant overhead.
  2. Do we just change the behavior outright? This is a breaking change since users relying on a disabled DAG can still accumulating events (that trigger runs later) as a feature will see it broken. We can maybe categorize the current behavior as a bug.

@boring-cyborg boring-cyborg Bot added the area:Scheduler including HA (high availability) scheduler label Apr 10, 2024
@uranusjr uranusjr marked this pull request as ready for review April 11, 2024 10:13
@uranusjr uranusjr requested review from XD-DENG, ashb and kaxil as code owners April 11, 2024 10:13
@uranusjr

Copy link
Copy Markdown
Member Author

I decided to not consider catchup at all here, and make the behavior change as simple as possible. A news fragment has been added to note the breaking change.

This adds an additional filter on consuming DAG, and only create a
DatasetDagRunQueue entry if the DAG is both active (i.e. still exists
in a DAG file) and unpaused.

There are still questions unanswered:

1. Do we consider catchup? The immediate problem here is catchup is not
   stored on DagModel, and checking it from DAG creates significant
   overhead.
2. Do we just change the behavior outright? This is a breaking change
   since users relying on a disabled DAG can still accumulating events
   (that trigger runs later) as a feature will see it broken. We can
   maybe categorize the current behavior as a bug.
@uranusjr uranusjr force-pushed the do-not-queue-inactive-dags branch from df7d731 to c74b69d Compare April 11, 2024 11:07
@eladkal

eladkal commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

I decided to not consider catchup at all here, and make the behavior change as simple as possible. A news fragment has been added to note the breaking change.

What does it mean in cases where dag has both dataset and time base scheduling?

@uranusjr

Copy link
Copy Markdown
Member Author

The catchup flag still affects time-based scheduling (and only that). I’ll call that out explicitly in the fragment.

@eladkal eladkal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tosheer

tosheer commented Apr 12, 2024

Copy link
Copy Markdown

@uranusjr / @eladkal but isn't above implementation will miss the use case in which any paused dag will just lose dataset events that came when DAG was paused / disabled. I agree on considering catchup will make implementation very complex.

To me default implementation should be just delivering all the events dag received during the time it was paused / disable without considering catchup. For the usecase when dag is deleted and comeback with same dag_id loosing dataset event is ok.

@uranusjr

Copy link
Copy Markdown
Member Author

The question, if you don’t want to miss the events, why do you also want to pause the DAG? If pausing a DAG doesn’t make it miss events, all those will still run when the DAG is unpaused. Why is it so important to pause the DAG and delay the runs?

@tosheer

tosheer commented Apr 12, 2024

Copy link
Copy Markdown

@uranusjr i checked the implementation and it is already perfectly aligned with what i said earlier. As all the dataset events will be received by the paused/deleted/disabled dag once its enabled and a new dataset event is received as then it was have an entry in the DatasetDagRunQueue and that perfectly make sense.

When i said miss the events i meant dataset events and not the DatasetDagRunQueue events. Apologies for confusion earlier

@hussein-awala hussein-awala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Scheduler including HA (high availability) scheduler type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAGs are able to see historical dataset events when created new / disabled - enabled / deleted - recreated.

5 participants