Broken master in "AllowPrometheusAlertsPerEnvironment#down deletes duplicate alerts before narrowing the index " / ee/spec/migrations/allow_prometheus_alerts_per_environment_spec.rb:62
Job #193337236 failed for f25b7ac6:
1) AllowPrometheusAlertsPerEnvironment#down deletes duplicate alerts before narrowing the index
Failure/Error:
prometheus_metrics.create!(
id: id,
project_id: project.id,
title: 'title',
query: 'query',
group: 1,
created_at: now,
updated_at: now,
common: false
)
ActiveRecord::RecordNotUnique:
Mysql2::Error: Duplicate entry '22' for key 'PRIMARY': INSERT INTO `prometheus_metrics` (`id`, `project_id`, `title`, `query`, `group`, `created_at`, `updated_at`) VALUES (22, 2, 'title', 'query', 1, '2019-04-09 12:22:08', '2019-04-09 12:22:08')
# ./config/initializers/connection_fix.rb:20:in `execute'
# ./config/initializers/active_record_locking.rb:14:in `_create_record'
# ./ee/spec/migrations/allow_prometheus_alerts_per_environment_spec.rb:99:in `metric'
# ./ee/spec/migrations/allow_prometheus_alerts_per_environment_spec.rb:42:in `block (3 levels) in <top (required)>'
# ./ee/spec/migrations/allow_prometheus_alerts_per_environment_spec.rb:49:in `block (3 levels) in <top (required)>'
# ./ee/spec/migrations/allow_prometheus_alerts_per_environment_spec.rb:62:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# Mysql2::Error:
# Duplicate entry '22' for key 'PRIMARY'
# ./config/initializers/connection_fix.rb:20:in `execute'
This also happen in the PG job so I think this is an ordering-dependent problem. Let's quarantine the spec.