Skip to content

Conversation

@tgxworld
Copy link
Contributor

The previous version of the migration is not idempotent and can result
in indexes created but marked as "invalid" by Postgres.

Per postgres documentation:

If a problem arises while scanning the table, such as a deadlock or a
uniqueness violation in a unique index,
the CREATE INDEX command will fail but leave behind an "invalid" index.
This index will be ignored for querying
purposes because it might be incomplete; however it will still consume
update overhead. The recommended recovery
method in such cases is to drop the index and try again to perform
CREATE INDEX CONCURRENTLY.

The previous version of the migration is not idempotent and can result
in indexes created but marked as "invalid" by Postgres.

Per postgres documentation:

If a problem arises while scanning the table, such as a deadlock or a
uniqueness violation in a unique index,
the CREATE INDEX command will fail but leave behind an "invalid" index.
This index will be ignored for querying
purposes because it might be incomplete; however it will still consume
update overhead. The recommended recovery
  method in such cases is to drop the index and try again to perform
  CREATE INDEX CONCURRENTLY.
@tgxworld
Copy link
Contributor Author

@nattsw Can you review this please? Thank you!

@tgxworld tgxworld merged commit 5e833a8 into main Mar 14, 2025
6 checks passed
@tgxworld tgxworld deleted the rerun_index_creation branch March 14, 2025 01:39
tgxworld added a commit to discourse/discourse that referenced this pull request Mar 17, 2025
…#31792)

This is a follow up to 6820622.

This commit addresses migrations that uses `remove_index` with the
`if_exists: true` option to drop an existing index before creating an
index using the `concurrently` option.

This commit also reruns two migration which may have caused indexes to
be left in an `invalid` state.

### Reviewers Note

Plugin tests are failing due to
discourse/discourse-translator#251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants