Project

General

Profile

Bug #15755

[hammer] product create fails with error: PG::Error: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"

Added by Justin Sherrill about 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Repositories
Target version:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1356622
Description of problem:
Product create test in our automation failed due to below issue:

DEBUG - >>> [qe-sat6-rhel7.satqe.lab.eng.rdu2.redhat.com] LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv product create --organization-id="616" --description="esVuNKYtkkFdqLxnDWyj" --name="<s>vyANYEvHYQOgLrcXrSiUWeKnAlebUTzbGMDTtqEnbwdUvbnxszNZjGbHXBHnnPNcvyGnVWCnyjTgNWM</s>" --label="nJgGLepWIpffwFjTVBEq"
2016-07-13 11:19:57 - robottelo.ssh - INFO - Instantiated Paramiko client 0x7f11b4baacd0
2016-07-13 11:20:01 - robottelo.ssh - INFO - Destroying Paramiko client 0x7f11b4baacd0
2016-07-13 11:20:01 - robottelo.ssh - INFO - Destroyed Paramiko client 0x7f11b4baacd0
2016-07-13 11:20:01 - robottelo.ssh - DEBUG - <<< stderr
[ERROR 2016-07-13 11:20:01 Exception] Task 3021f78f-1b7f-4814-89ba-0f7734a2ae69: ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"
DETAIL: Key (cp_id)=(ff80808155e4aaf80155e4d7e01207b8) already exists.
: INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
Could not create the product:
Task 3021f78f-1b7f-4814-89ba-0f7734a2ae69: ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"
DETAIL: Key (cp_id)=(ff80808155e4aaf80155e4d7e01207b8) already exists.
: INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
[ERROR 2016-07-13 11:20:01 Exception]

This is then reproducible on my setup when I was trying to create multiple product/repo one after another. So looks like issue with some race condition

Could not create the product:
Task 082171b1-5b16-46e4-a96a-e4e89adac94b: ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"
DETAIL: Key (cp_id)=(8a93a2bd55e8245f0155e8ef7e5b03a1) already exists.
: INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
Product name is Sat6Tools7 and id is: 142
Could not create the repository:
Task 6b379314-b07c-4aa1-9dec-2a13202f15e2: Katello::Errors::CandlepinError: Runtime Error RESTEASY001185: Could not find resource for relative : /products//content/1468491862827 of full path: https://localhost:8443/candlepin/products//content/1468491862827?enabled=true at org.jboss.resteasy.core.registry.PathParamSegment.matchPattern:209

Version-Release number of selected component (if applicable):
sat62 GA snap20.1

How reproducible:

Steps to Reproduce:
1. create product A/repo A
2. create product B/ repo B
3.

Actual results:
Could not create the product:
Task 082171b1-5b16-46e4-a96a-e4e89adac94b: ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"
DETAIL: Key (cp_id)=(8a93a2bd55e8245f0155e8ef7e5b03a1) already exists.
: INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
Product name is Sat6Tools7 and id is: 142

Expected results:
product create should work

Additional info:

Associated revisions

Revision 04383573 (diff)
Added by Justin Sherrill about 3 years ago

Fixes #15755 - handle race condition on pool import (#6196)

Revision bc6be6e3 (diff)
Added by Justin Sherrill about 3 years ago

Refs #15755 - index pools in a run phase (#6200)

so it does not execute in a transaction. Its safe for this to
re-run, as its idempotent, similar to content indexing

History

#1 Updated by The Foreman Bot about 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Justin Sherrill
  • Pull request https://github.com/Katello/katello/pull/6196 added

#2 Updated by Justin Sherrill about 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by The Foreman Bot about 3 years ago

  • Pull request https://github.com/Katello/katello/pull/6200 added

#4 Updated by Justin Sherrill almost 3 years ago

  • Legacy Backlogs Release (now unused) set to 143
  • Difficulty set to medium

Also available in: Atom PDF