ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique c...

https://sentry.gitlap.com/gitlab/gitlabcom/issues/17179/

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_project_authorizations_on_user_id_project_id_access_level"
DETAIL:  Key (user_id, project_id, access_level)=(761592, 1315991, 30) already exists.

  app/models/project_authorization.rb:15:in `block in insert_authorizations'
    connection.execute <<-EOF.strip_heredoc
  app/models/project_authorization.rb:10:in `each'
    rows.each_slice(per_batch) do |slice|
  app/models/project_authorization.rb:10:in `each_slice'
    rows.each_slice(per_batch) do |slice|
  app/models/project_authorization.rb:10:in `insert_authorizations'
    rows.each_slice(per_batch) do |slice|
  app/services/users/refresh_authorized_projects_service.rb:81:in `block in update_authorizations'
    ProjectAuthorization.insert_authorizations(add) unless add.empty?
...
(57 additional frame(s) were not displayed)

ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_project_authorizations_on_user_id_project_id_access_level"
DETAIL:  Key (user_id, project_id, access_level)=(761592, 1315991, 30) already exists.
: INSERT INTO project_authorizations (user_id, project_id, access_level)
VALUES (761592, 1315991, 30), (761592, 1827894, 40), (761592, 1827895, 40), (761592, 1827896, 40), (761592, 1827897, 40), (761592, 1827898, 40), (761592, 1827900, 40), (761592, 1827901, 40), (761592, 1827903, 40), (761592, 1827904, 40), (761592, 1827907, 40), (761592, 1859394, 40), (761592, 1929215, 40)