Skip to content

Update prepare_async_index migration helper to avoid subtransaction

Krasimir Angelov requested to merge prepare-async-index-no-subtxn into master

What does this MR do?

safe_find_or_create_by! creates a savepoint if already in transaction, which is usually the case for migrations. This updates the helper to use upsert instead in order to avoid subtransactions.

safe_find_or_create_by! creates a savepoint if already in transaction, which is usually the case for migrations. This updates the helper to use 'find_or_create_by!` instead in order to avoid subtransactions.

find_or_create_by! is not atomic, but given this helper is used only on migrations and they are never executed in parallel, this is fine.

Also changes the helper to update index definition if the record already exists and there is new definition, something we state in the method comment but were not actually doing.

Related to #339667 (closed).

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Krasimir Angelov

Merge request reports