Skip to content

Conversation

jacklinke
Copy link

Update delete_expired method of ResultManager to use writable database.

Resolves #357

@auvipy auvipy self-requested a review January 17, 2023 08:48
Copy link
Member

@auvipy auvipy left a 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

@auvipy auvipy closed this Feb 5, 2023
@auvipy auvipy reopened this Feb 5, 2023
Copy link
Member

@auvipy auvipy left a 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()):
Copy link
Member

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?

@matmunn
Copy link

matmunn commented Mar 18, 2024

@jacklinke any joy on this one? I'm running into the same issue that you are

@AllexVeldman
Copy link
Contributor

Just as a heads-up, #427 also needs a testcase with a read-only connection (See my comment for a suggested approach: #427 (comment))

@auvipy auvipy requested a review from Copilot October 2, 2025 12:53
Copy link

@Copilot Copilot AI left a 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.

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.

The delete_expired method of ResultManager sometimes selects read-only database

4 participants