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

Resolve trigger assignment race condition #27072

Merged
merged 3 commits into from
Oct 31, 2022

Conversation

pavansharma36
Copy link
Contributor

@pavansharma36 pavansharma36 commented Oct 15, 2022

closes: #27057

Added for update to avoid race condition between mutiple triggerer process


^ 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.

@pavansharma36 pavansharma36 changed the title 27057 : assign trigger in single queries to avoid race condition 27057 : assign trigger with locks Oct 15, 2022
@dstandish dstandish changed the title 27057 : assign trigger with locks Resolve trigger assignment race condition Oct 17, 2022
@pavansharma36
Copy link
Contributor Author

@dstandish

Found util to add row locks by configuration or if dialect supports, updated with that change.

@dstandish
Copy link
Contributor

cool 👍

looks like you maybe need to get your pre-commit hooks working locally... the formatting looks a little funky, but let's see what tests say

@potiuk
Copy link
Member

potiuk commented Oct 24, 2022

I re-based it to account for failed image build. And it looks good in general.

skip_locked=True,
).all()
if trigger_ids_query:
session.query(cls).filter(cls.id.in_([i.id for i in trigger_ids_query])).update(
Copy link
Member

@uranusjr uranusjr Oct 24, 2022

Choose a reason for hiding this comment

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

Would it be possible to transform trigger_ids_query to a subquery so this can be done in one db call instead of two?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@uranusjr As discussed update with limit is not supported, and adding subquery on same table is not supported in mysql

@potiuk potiuk merged commit 9c737f6 into apache:main Oct 31, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 31, 2022

Awesome work, congrats on your first merged pull request!

@pavansharma36 pavansharma36 deleted the bugfix/27057 branch November 1, 2022 16:02
@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in multiple triggerer process can lead to both picking up same trigger.
6 participants