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

Replace retry with backoff, add backoff to all Freesound requests #4663

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

AetherUnbound
Copy link
Collaborator

Fixes

Fixes #4594 by @stacimc

Description

Warning

This should not be merged until a deployment can be made immediately after, since it introduces new dependencies.

This PR makes two major changes:

  • Replaces the retry with backoff
  • Adds an exponential backoff to all requests made to Freesound during ingestion

The latter change is relatively straightforward: we encounter tons of exceptions during the Freesound ingestion process that seem to be transient and ultimately get resolved when checked later. However this causes significant disruptions in the execution of the DAG itself, since it often requires that maintainers restart the DAG with SKIP_INGESTION_ERRORS enabled for it. This change allows requests to be retried with an exponential backoff up to a max time (2 minutes for now) if they match the HTTP codes 400 or 503. On all other codes, the exception is raised and retries (outside of the normal ones for the DelayedRequester) are not attempted.

The former change is motivated by the above. retry is a Python library that hasn't been updated since 2016, and only supports fairly basic retry conditions. backoff on the other hand has been updated as recently as 2022 and supports much more complexity in retry conditions. With the above case, we only wanted to retry on HTTPErrors with a specific return code; that was not possible with retry but is now possible with backoff. This should give us some additional flexibility moving forward too!

Testing Instructions

I added new tests specifically for the conditions mentioned above. You can also run the freesound_workflow DAG locally to ensure everything behaves normally (and maybe encounter one of the above cases if you're lucky!).

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@AetherUnbound AetherUnbound requested a review from a team as a code owner July 26, 2024 20:34
@AetherUnbound AetherUnbound requested review from krysal and stacimc and removed request for a team July 26, 2024 20:34
@openverse-bot openverse-bot added 🧱 stack: catalog Related to the catalog and Airflow DAGs 🟧 priority: high Stalls work on the project or its dependents 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository labels Jul 26, 2024
@openverse-bot
Copy link
Collaborator

Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR:

@krysal
@stacimc
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 2 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2.

@AetherUnbound, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM, except a nit about the position of a comment.

Comment on lines 57 to 61
# Freesound often tends to be flaky when making requests during ingestion.
# For the flaky HTTP errors above, we wait some time before trying the request
# again in the hopes that the upstream issues resolve in that time:
# * 400 - Although framed as bad requests, these appear to succeed later
# * 503 - Service unavailable, so we should just try to wait
Copy link
Member

Choose a reason for hiding this comment

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

This comment would've been more helpful before L39.

Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

Nice to prune and keep updated dependencies! LGTM.

Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Great idea! It would be wonderful if this eases some of the flakiness we've experienced🤞

@AetherUnbound AetherUnbound merged commit 05f8c55 into main Aug 15, 2024
43 checks passed
@AetherUnbound AetherUnbound deleted the fix/flaky-freesound-errors branch August 15, 2024 16:49
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: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Flaky 503s when trying to fetch Freesound audioset info
5 participants