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 DagProcessorJob integration for standalone dag-processor #30278

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Mar 24, 2023

The DagProcessorJob integration implemented in #28799 was not complete. It missed a few crucial changes:

  • importing DagProcessorJob in airflow/models/init.py - not importing it there caused airflow jobs check to fail, when querying DagProcessorJob in the BaseJob query, because the DagProcessorJob was not registered by the time the query was run (so polimorphic ORM model retrieval was not aware of DagProcessorJob model.

  • airflow jobs check command did not have DagProcessorJob added as valid job type, so it was impossible to monitor for it

  • also the processor manager did not set heartbeats periodically, so the Job for the DagFileProcessor was considered as not alive pretty quickly even if standalone dag-processor was running.

This PR fixes all three problems.

Fixes: #30251


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

The DagProcessorJob integration implemented in apache#28799 was not
complete. It missed a few crucial changes:

* importing DagProcessorJob in airflow/models/__init__.py - not
  importing it there caused `airflow jobs check` to fail, when
  querying DagProcessorJob in the BaseJob query, because
  the DagProcessorJob was not registered by the time the query
  was run (so polimorphic ORM model retrieval was not aware of
  DagProcessorJob model.

* airflow jobs check command did not have DagProcessorJob
  added as valid job type, so it was impossible to monitor for it

* also the processor manager did not set heartbeats periodically,
  so the Job for the DagFileProcessor was considered as not alive
  pretty quickly even if standalone dag-processor was running.

This PR fixes all three problems.

Fixes: apache#30251
@boring-cyborg boring-cyborg bot added area:CLI area:Scheduler including HA (high availability) scheduler labels Mar 24, 2023
@potiuk potiuk requested a review from pierrejeambrun March 24, 2023 12:52
@potiuk potiuk added this to the Airflow 2.5.3 milestone Mar 24, 2023
@pierrejeambrun pierrejeambrun added the type:bug-fix Changelog: Bug Fixes label Mar 24, 2023
@pierrejeambrun pierrejeambrun merged commit c858509 into apache:main Mar 24, 2023
pierrejeambrun pushed a commit that referenced this pull request Mar 24, 2023
The DagProcessorJob integration implemented in #28799 was not
complete. It missed a few crucial changes:

* importing DagProcessorJob in airflow/models/__init__.py - not
  importing it there caused `airflow jobs check` to fail, when
  querying DagProcessorJob in the BaseJob query, because
  the DagProcessorJob was not registered by the time the query
  was run (so polimorphic ORM model retrieval was not aware of
  DagProcessorJob model.

* airflow jobs check command did not have DagProcessorJob
  added as valid job type, so it was impossible to monitor for it

* also the processor manager did not set heartbeats periodically,
  so the Job for the DagFileProcessor was considered as not alive
  pretty quickly even if standalone dag-processor was running.

This PR fixes all three problems.

Fixes: #30251
(cherry picked from commit c858509)
@potiuk potiuk deleted the fix-dag-processor-standalone-job branch April 4, 2023 18:26
@potiuk potiuk mentioned this pull request Apr 27, 2023
2 tasks
potiuk added a commit to potiuk/airflow that referenced this pull request Apr 27, 2023
The standalone file processor as of apache#30278 introduced accidentally
an artifficial delay between dag processing by adding heartbeat
but missing to set "only_if_necessary" flag to True.

If your dag file processing has been fast (faster than the
scheduler job_heartbeat_sec) this introduced unnecessary pause
between the next dag file processor loop (up until the time
passed), it also introduced inflation of the
dag_processing_last_duration metrics (it would always show minimum
job_heartbeat_sec)

Adding "only_if_necessary" flag fixes the problem.

Fixes: apache#30593
Fixes: apache#30884
potiuk added a commit that referenced this pull request Apr 27, 2023
The standalone file processor as of #30278 introduced accidentally
an artifficial delay between dag processing by adding heartbeat
but missing to set "only_if_necessary" flag to True.

If your dag file processing has been fast (faster than the
scheduler job_heartbeat_sec) this introduced unnecessary pause
between the next dag file processor loop (up until the time
passed), it also introduced inflation of the
dag_processing_last_duration metrics (it would always show minimum
job_heartbeat_sec)

Adding "only_if_necessary" flag fixes the problem.

Fixes: #30593
Fixes: #30884
ephraimbuddy pushed a commit that referenced this pull request Apr 27, 2023
The standalone file processor as of #30278 introduced accidentally
an artifficial delay between dag processing by adding heartbeat
but missing to set "only_if_necessary" flag to True.

If your dag file processing has been fast (faster than the
scheduler job_heartbeat_sec) this introduced unnecessary pause
between the next dag file processor loop (up until the time
passed), it also introduced inflation of the
dag_processing_last_duration metrics (it would always show minimum
job_heartbeat_sec)

Adding "only_if_necessary" flag fixes the problem.

Fixes: #30593
Fixes: #30884
(cherry picked from commit 00ab45f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI area:Scheduler including HA (high availability) scheduler type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DagProcessor restart constantly when it running as standalone process
2 participants