ActiveRecord::RecordInvalid: Validation failed: Name has already been taken

https://sentry.gitlab.net/gitlab/gitlabcom/issues/3407702/?referrer=gitlab_plugin

ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
  lib/gitlab/database/load_balancing/connection_proxy.rb:120:in `block in write_using_load_balancer'
    connection.send(...)
  lib/gitlab/database/load_balancing/load_balancer.rb:115:in `block in read_write'
    yield connection
  lib/gitlab/database/load_balancing/load_balancer.rb:191:in `retry_with_backoff'
    return yield
  lib/gitlab/database/load_balancing/load_balancer.rb:111:in `read_write'
    retry_with_backoff do
  lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `write_using_load_balancer'
    @load_balancer.read_write do |connection|
...
(154 additional frame(s) were not displayed)

Validation failed: Name has already been taken

Implementation Plan

  • Add transactions back in order to avoid race condition between deletion and creation of approval rules
  • Add validation in case scan result policies rules have the same name as the other of the report_approvers type (coverage check and license check)
  • Remove left over from the migration (related to Vulnerability-Check) that got in the way after the new change related to synchronization of open merge requests.
Edited by Zamir Martins