-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Add retry logic in the scheduler for updating trigger timeouts in case of deadlocks. #41429
Add retry logic in the scheduler for updating trigger timeouts in case of deadlocks. #41429
Conversation
From our observations in production, the deadlock issue has not occurred since we applied our own patch to Airflow. It seems that retry can tolerate the issue to some extent. However, to completely eliminate it, processes need to maintain the same data access order. There is still room for further optimization. Please kindly review this when you have time if this is the right fix, and if you have any suggestions, please let me know @kaxil @ashb @XD-DENG @shahar1 |
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.
Apologies for the delay, I accidentally overlooked this PR after your fixes - it looks OK, I'd be happy for a second opinion though.
@TakawaAkirayo Could you please add a newsfragment?
@shahar1 Many thanks for the review. I just added a newsfragment regarding this https://github.com/apache/airflow/blob/main/contributing-docs/16_contribution_workflow.rst. please have a check. |
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.
Approved, but static checks need to be fixed.
@jscheffl Sure, I've already fixed the static check, and the checks have passed now. |
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
…e of deadlocks. (apache#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check (cherry picked from commit 00589cf)
…outs in case of deadlocks. (#41429) (#42651) * Add retry logic in the scheduler for updating trigger timeouts in case of deadlocks. (#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check (cherry picked from commit 00589cf) * Fix type-ignore comment for typing changes (#42656) --------- Co-authored-by: TakawaAkirayo <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]>
…e of deadlocks. (apache#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check
…outs in case of deadlocks. (#41429) (#42651) * Add retry logic in the scheduler for updating trigger timeouts in case of deadlocks. (#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check (cherry picked from commit 00589cf) * Fix type-ignore comment for typing changes (#42656) --------- Co-authored-by: TakawaAkirayo <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]>
…outs in case of deadlocks. (#41429) (#42651) * Add retry logic in the scheduler for updating trigger timeouts in case of deadlocks. (#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check (cherry picked from commit 00589cf) * Fix type-ignore comment for typing changes (#42656) --------- Co-authored-by: TakawaAkirayo <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]>
…e of deadlocks. (apache#41429) * Add retry in update trigger timeout * add ut for these cases * use OperationalError in ut to describe deadlock scenarios * [MINOR] add newsfragment for this PR * [MINOR] refactor UT for mypy check
After upgrading from 2.9.0 to 2.10.3 the deadlock still exists. It's even worst, now it makes the sensor (in reschedule mode) fail after a random number of poke. |
Please open new issue and provide all information about your case then and add reference to it as "similar to #41429". It might be the same or different issue manifesting tne same way and the more information you provide, the higher chance someone will attempt to look at it and try to diagnose and fix it. When you just comment on a closed issue "thse issue is still not solved" with very vague description and without details explaining what you mean, the chances that someone will look at it are very slim, almost none. You increase your chances by creating new issue with as detailed explanation of your circumstances as possible. Up to you if you want to increase your chances of getting help. |
@klacire This change primarily attempts to tolerate the scheduler's failure caused by the deadlock issue, rather than completely eliminating the deadlock. You can refer to the previous comments; we still have work to do to eliminate the deadlock entirely. Could you please open new issue and provide your error stack trace? Currently I don't see much of a definitive connection between your issue and this change. |
I already can find an issue mentioning the same problem : #41428 |
@klacire Ok, what about this issue: |
same root cause in my opinion. No need to duplicate for now. |
related: #41428
The scheduler job raise exception on database dead lock and exist.
This should occur when the scheduler and trigger compete for a row lock, based on MySQL database query log analysis. Since the trigger already includes a retry mechanism on update(Trigger.clean_unused), we should add a retry mechanism here as well.
^ 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.