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

Drop invalid index in safe_add_index #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dgsuarez
Copy link

@dgsuarez dgsuarez commented Sep 7, 2023

Hi! Saw this TODO in the code, we've been running something similar in our codebase, so better contribute it back :)

Allow safe_add_index to be seamlessly retried.

When the add_index...concurrently fails, the index is left in Postgres with INVALID status.

The new code drops the index if it's found and invalid. With this, if the migration fails because of a lock timeout for example, on retry it can work. Without it the retries always fail until you manually drop the index.

@dgsuarez dgsuarez marked this pull request as ready for review September 7, 2023 02:42
@dgsuarez
Copy link
Author

dgsuarez commented Sep 8, 2023

Small update to fix the errors in pre-6.1 rails versions

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.

None yet

1 participant