Skip to content

Explicitly state index name for create and remove

Andreas Brandl requested to merge ab/forward-fix-lock-version-migration into master

What does this MR do?

This is a roll-forward type of response to the problem described in #223041 (comment 380982365).

Background

Index definitions can be partial, i.e. supplied with a where: ? clause. This is an inherent part of the index definition, but our migration helpers have a bug in that regard: When adding a new index through add_index_concurrently, we first check if the index already exists (thereby making the operation idempotent). This check however does not include the where clause. This leads to false-positives where we skip index creation because another index already exists, which is deemed identical but in fact is not (due to differences in the where clause).

In our case, the two seemingly identical indexes where:

    "merge_request_mentions_temp_index" btree (id) WHERE description ~~ '%@%'::text OR title::text ~~ '%@%'::text
    "index_merge_requests_on_id" btree (id) WHERE lock_version IS NULL

The bug should be fixed in the migration helpers (issue pending - I'll follow up here).

Since we're short before releasing %13.2, we are fixing a migration affected by this directly: We specify index names explicitly, which makes existence checks reliable.

This should be included in %13.2 to make sure the migration introduced in !36893 (merged) succeeds.

Edited by Andreas Brandl

Merge request reports