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

Retry on concurrency issue(s) #32

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Retry on concurrency issue(s) #32

wants to merge 1 commit into from

Conversation

pydanny
Copy link
Contributor

@pydanny pydanny commented Nov 7, 2024

Using the patch pattern from fastai, but without the patch decorator. Wraps the db.execute() method to retry on what are probably concurrency issues (need to confirm with new load tests)

Challenge: Unfortunately

            # Catch the unfortunately generic error sqlite3.OperationalError
            # to determine if this is a concurrency issue
            if "cannot start a transaction within a transaction" in str(e).lower():
                # Probably a concurrency issue, retry
                # We could make this more precise with time.perf_counter but
                # imprecision here is a good thing as it adds jitter
                # Yes, this avoids exponential backoff for REASONS
                time.sleep(0.001)
                continue
            # Since this isn't a transaction failure, we re-raise the issue so
            # other logic in this library can handle it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant