Creating a merge request results in a 500 when there are invalid project approval rules (empty users / groups)
https://sentry.gitlab.net/gitlab/gitlabcom/issues/1119550/
Users receive a 500
error when attempting to create merge requests in certain repositories.
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "any_approver_merge_request_rule_type_unique_index"
DETAIL: Key (merge_request_id, rule_type)=(44945875, 4) already exists.
active_record/connection_adapters/postgresql_adapter.rb:611:in `async_exec_params'
@connection.exec_params(sql, type_casted_binds)
active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
@connection.exec_params(sql, type_casted_binds)
active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
yield
active_support/concurrency/share_lock.rb:187:in `yield_shares'
yield
active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
@lock.yield_shares(compatible: [:load]) do
...
(255 additional frame(s) were not displayed)
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "any_approver_merge_request_rule_type_unique_index"
DETAIL: Key (merge_request_id, rule_type)=(44945875, 4) already exists.
: INSERT INTO "approval_merge_request_rules" ("created_at", "updated_at", "merge_request_id", "approvals_required", "name", "rule_type") VALUES ('2019-12-12 21:09:25.608140', '2019-12-12 21:09:25.608140', 44945875, 2, 'All Members', 4) RETURNING "id"
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "any_approver_merge_request_rule_type_unique_index"
DETAIL: Key (merge_request_id, rule_type)=(44945875, 4) already exists.
: INSERT INTO "approval_merge_request_rules" ("created_at", "updated_at", "merge_request_id", "approvals_required", "name", "rule_type") VALUES ('2019-12-12 21:09:25.608140', '2019-12-12 21:09:25.608140', 44945875, 2, 'All Members', 4) RETURNING "id"
Zendesk Examples
- https://gitlab.zendesk.com/agent/tickets/141459
- https://gitlab.zendesk.com/agent/tickets/141462
- https://gitlab.zendesk.com/agent/tickets/141471
- https://gitlab.zendesk.com/agent/tickets/141465
- https://gitlab.zendesk.com/agent/tickets/143134
- https://gitlab.zendesk.com/agent/tickets/142609
- https://gitlab.zendesk.com/agent/tickets/143976
- https://gitlab.zendesk.com/agent/tickets/144812
- https://gitlab.zendesk.com/agent/tickets/144942
Possible workaround(s)
From #42433 (comment 259652543)
recommend that they either delete the blank approval rule or re-create it with a groups or user
Edited by Muhamed Huseinbašić