-
Notifications
You must be signed in to change notification settings - Fork 212
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 elasticsearch concurrency tags for Airflow #3910
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…_new_es_index dag
* `point_alias` needs to have trigger_rule=TriggerRule.NONE_FAILED, because the previous step to remove existing alias my be skipped * however, this is a problem for DAGs that import the entire point_alias taskGroup and try to skip it using a branching operator. Because `point_alias` runs when NONE_FAILED, it will try to run even though the entire taskgroup has been skipped. * easiest solution is to have all the individual tasks in the point_alias group individually handle skipping if the appropriate params haven't been passed in
stacimc
added
🟨 priority: medium
Not blocking but should be addressed soon
🛠 goal: fix
Bug fix
💻 aspect: code
Concerns the software code in the repository
🧰 goal: internal improvement
Improvement that benefits maintainers, not users
🧱 stack: catalog
Related to the catalog and Airflow DAGs
labels
Mar 13, 2024
openverse-bot
added
the
🏷 status: label work required
Needs proper labelling before it can be worked on
label
Mar 13, 2024
Full-stack documentation: https://docs.openverse.org/_preview/3910 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. Changed files 🔄: |
Closing in favor of #3921 to disentangle merge issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
💻 aspect: code
Concerns the software code in the repository
🧰 goal: internal improvement
Improvement that benefits maintainers, not users
🟨 priority: medium
Not blocking but should be addressed soon
🧱 stack: catalog
Related to the catalog and Airflow DAGs
🏷 status: label work required
Needs proper labelling before it can be worked on
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Fixes #3891 by @stacimc
Blocked, this needs to be rebased on #3890 when merged (missing latest changes from that PR)
TODO should also add an exception for relationship between staging_db_restore and the proportional index DAG.
Description
We now have quite a few DAGs that all operate on Elasticsearch or the underlying databases, and therefore must not run concurrently. We've been using the
prevent_concurrency_with_dags
andwait_for_external_dags
utils to accomplish this in each DAG, by passing in a hard-coded list of the external DAGs we want to either wait on or otherwise prevent concurrency with. Since this list is hard-coded for each DAG, it is extremely easy to miss dependencies especially as DAGs are added and changed. A few were missed in the implementation of the Search Relevancy project so far.This PR introduces two new Tags that are used to identify DAGs as being part of a "concurrency group":
production_es_concurrency
andstaging_es_concurrency
. Each DAG in these groups have been given the appropriate tag (so for example,create_new_staging_es_index
andstaging_database_restore
both have thestaging_es_concurrency
tag). The concurrency tasks have been updated to accept the name of the tag you want to select on, rather than a hard coded list, ie:^ This will select all the DAGs that have the given
tag
, except for the running DAG/the DAG that called the task, and fail immediately if any of them are running.So now if you add a new ES dag, rather than having to manually update a bunch of lists of DAG dependencies on every single other ES dag, you just have to remember to add the appropriate
tag
to your new DAG. The concurrency util will raise an error if you forget, as well.Additional thoughts/alternatives
This comment on the issue explains why it wasn't possible to use the existing feature of Airflow pools to do this. Tags also have the benefit of being very visible in the UI and easy to filter by.
Testing Instructions
These are the intended concurrency groups:
staging_es_concurrency
production_es_concurrency
For each DAG, run the DAG and check that the appropriate DAGs were waited on/prevented_concurrency_with. You can do this by looking at the logs for the
get_dags_in_<tag>_group
task, and then checking that the correct number of mapped tasks were made. (Example:create_proportional_by_source_staging_index
is in the staging group which has 6 dags. It has aprevent_concurrency_with_dag
task generated for every other DAG in the group except itself).Airflow 2.9 is supposed to include the ability to prove meaningful names for dynamically mapped tasks (instead of just a numerical index), which will make this much easier to read at-a-glance once we upgrade!
Note: The data refreshes are a little special. They use the
SingleRunExternalDagSensor
to wait on each other, so in theirwait_for_es_dags
task they should only wait on the other production ES Dags (5 dags total -- the two filtered index, create_new_production_es_index, and point_production_es_index).Test the actual concurrency utils still works
We should also test the actual concurrency for at least a few options. The easiest way to do this is to trigger them in sequence through the Airflow CLI. Make sure the relevant DAGs are turned on in Airflow, then run
just catalog/shell
and:A general tip for remembering how the concurrency checks should work: scheduled DAGs (data refreshes, staging database restore) will wait if a conflicting DAG is running, and resume once it completes. DAGs that are only run manually (create_new_es_index, create_filtered_index, recreate_full_staging_index) fail immediately if a conflicting DAG is running.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin