Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #28307
Closed
Open
Issue created Feb 16, 2017 by Clement Ho@ClemMakesAppsContributor

Sporadic rspec failures due to PG::UniqueViolation

This has happened to me on several occasions across different MRs and different spec files.

Most recently, I did the following rspec command: rspec spec/features/merge_requests/filter_merge_requests_spec.rb which resulted in the following:

1) Filter merge requests for assignee from mr#index assignee does not change when closed link is clicked
     Failure/Error: let!(:project)   { create(:project) }

     ActiveRecord::RecordNotUnique:
       PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_routes_on_source_type_and_source_id"
       DETAIL:  Key (source_type, source_id)=(Namespace, 2) already exists.
       : INSERT INTO "routes" ("source_type", "path", "name", "source_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING “id”
#
# ....
# ------------------
     # --- Caused by: ---
     # PG::UniqueViolation:
     #   ERROR:  duplicate key value violates unique constraint "index_routes_on_source_type_and_source_id"
     #   DETAIL:  Key (source_type, source_id)=(Namespace, 2) already exists.
     #   /.rvm/gems/ruby-2.3.2/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:602:in `exec_prepared'
Assignee
Assign to
Time tracking