-
Notifications
You must be signed in to change notification settings - Fork 220
Ensure delete_expired
uses writable database.
#358
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will need to update the tests as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add / update tests to make the CI green.
def delete_expired(self, expires): | ||
"""Delete all expired results.""" | ||
with transaction.atomic(using=self.db): | ||
with transaction.atomic(using=self.database_for_write()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also resolve the merge conflict please?
@jacklinke any joy on this one? I'm running into the same issue that you are |
Just as a heads-up, #427 also needs a testcase with a read-only connection (See my comment for a suggested approach: #427 (comment)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a database routing issue by ensuring the delete_expired
method uses the writable database instead of the default read database. This prevents potential failures when using read/write database splitting configurations.
- Extracted database selection logic into a reusable
database_for_write()
method - Updated
delete_expired
to use the writable database for atomic transactions - Refactored
connection_for_write()
to use the new helper method
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Update
delete_expired
method of ResultManager to use writable database.Resolves #357