-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Double-check TaskInstance state if it differs from the Executor state. #43063
Double-check TaskInstance state if it differs from the Executor state. #43063
Conversation
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
aea56b9
to
543afb2
Compare
cc: @dstandish -> maybe with your recent backfll experience you can comment on that - that seems like a good candidate to fix for 2.10 if it solves the issue (regardless from the fact that in Airflow 3 backfill is going to be differently). |
lemme see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no concerns with this change
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
#43063) * Double-check TaskInstance state if it differs from Executor. * Update airflow/jobs/backfill_job_runner.py * Update airflow/jobs/backfill_job_runner.py * Update airflow/jobs/backfill_job_runner.py * Update airflow/jobs/backfill_job_runner.py * Update airflow/jobs/backfill_job_runner.py * Update airflow/jobs/backfill_job_runner.py --------- Co-authored-by: Utkarsh Sharma <utkarsharma2@gmail.com> (cherry picked from commit 90d6332)
closes: #42991 (discussion)
In the course of investigating #42991 I am a bit suspicious that there is a race condition between the DB fetch on line 285 and the executor state check on line 312.
Basically my suspicion is that the following order of operations is sometimes happening:
More details on my situation in the above linked discussion, but important to know is in my case the worker is completing the task in about 300 milliseconds.
Therefore, I propose that the backfill job should "double-check" the task instance state if it is different from executor state by refreshing from DB. If the state is still different then fall back to the old logic of assuming that the task state has changed externally.
I am not sure if I've picked the right base for this PR. The backfill stuff is being totally re-written for Airflow 3 as part of AIP-78 so I wouldn't know where to make this change or even if the same bug exists there.
Update 2024-10-17
#42991 (comment) I patched the change into my deployment and am seeing the added log line being emitted, and not followed by the
The executor reported that the task instance finished with state success, but the task instance's state attribute is queued
message. This tells me that the refresh is probably necessary under such circumstances.^ 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.