Skip to content

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.

2 participants