Skip to content

Composite metric identifier index

Ryan Cobb requested to merge rc/enforce_unique_metrics_id_across_project into master

What does this MR do?

In support of #28241 (closed)

This is the first of two MRs to fix a bug where metric identifier uniqueness was enforced across all metrics. We want metric identifier to be unique only across the scope of a project.

  1. This MR will add a new composite index on metric identifier and project_id.
  2. A follow up MR will remove the current index on metric identifier. !35912 (merged)

up

== 20200629192638 AddUniqIndexOnMetricIdentifierAndProjectId: migrating =======
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:prometheus_metrics, [:identifier, :project_id], {:unique=>true, :algorithm=>:concurrently})
   -> 0.0036s
-- add_index(:prometheus_metrics, [:identifier, :project_id], {:unique=>true, :algorithm=>:concurrently})
   -> 0.0047s
== 20200629192638 AddUniqIndexOnMetricIdentifierAndProjectId: migrated (0.0088s)

down

== 20200629192638 AddUniqIndexOnMetricIdentifierAndProjectId: reverting =======
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:prometheus_metrics, [:identifier, :project_id], {:algorithm=>:concurrently})
   -> 0.0040s
-- remove_index(:prometheus_metrics, {:algorithm=>:concurrently, :column=>[:identifier, :project_id]})
   -> 0.0045s
== 20200629192638 AddUniqIndexOnMetricIdentifierAndProjectId: reverted (0.0089s)

Screenshots

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 Ryan Cobb

Merge request reports

Loading