Skip to content

Remove TMP index in emails table

Adam Hegyi requested to merge remove-tmp-emails-index into master

What does this MR do?

This MR removes a temporary index in the emails table. The index was introduced for a security background MR which was executed about 6 months ago.

Related file: db/post_migrate/20200615111857_unconfirm_wrongfully_verified_emails.rb

Migrations

UP:

== 20210106153021 DropTmpIndexOnEmails: migrating =============================
-- transaction_open?()
   -> 0.0001s
-- indexes(:emails)
   -> 0.0033s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- remove_index(:emails, {:algorithm=>:concurrently, :name=>"tmp_index_for_email_unconfirmation_migration"})
   -> 0.0028s
-- execute("RESET ALL")
   -> 0.0002s
== 20210106153021 DropTmpIndexOnEmails: migrated (0.0090s) ====================

DOWN:

== 20210106153021 DropTmpIndexOnEmails: reverting =============================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:emails, :id, {:where=>"confirmed_at IS NOT NULL", :name=>"tmp_index_for_email_unconfirmation_migration", :algorithm=>:concurrently})
   -> 0.0021s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- add_index(:emails, :id, {:where=>"confirmed_at IS NOT NULL", :name=>"tmp_index_for_email_unconfirmation_migration", :algorithm=>:concurrently})
   -> 0.0163s
-- execute("RESET ALL")
   -> 0.0004s
== 20210106153021 DropTmpIndexOnEmails: reverted (0.0193s) ====================

The index is not in use:

 schemaname | tablename |                  indexname                   | num_rows | table_size | index_size | unique | number_of_scans | tuples_read | tuples_fetched
------------+-----------+----------------------------------------------+----------+------------+------------+--------+-----------------+-------------+----------------
 public     | emails    | tmp_index_for_email_unconfirmation_migration |   429979 | 47 MB      | 4776 kB    | N      |               0 |           0 |              0

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • 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 Adam Hegyi

Merge request reports