Project

General

Profile

Actions

Bug #30322

closed

ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint

Added by Hao Yu almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Content Views
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Cloned from: https://bugzilla.redhat.com/show_bug.cgi?id=1854026

Description of problem:
Removing the latest content view version doesn't delete the Katello::DockerMetaTag records. This will cause duplicated/orphaned Katello::DockerMetaTag records after publishing a new version. If a tag has both schema v1 manifest and schema v2 manifest then the CV or CCV will fail to publish with the following error:

-------------------------------------
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_docker_meta_tags_on_schema1_id_and_schema2_id"
DETAIL: Key (schema1_id, schema2_id)=(340545, 340570) already exists.
: INSERT INTO "katello_docker_meta_tags" ("schema1_id", "schema2_id", "name") VALUES ($1, $2, $3) RETURNING "id"

Steps to Reproduce:
1. Create a CCV and add a CV that contains a docker repo.
2. Publish the CCV which will create version 1.
3. Run the following commands to get all orphaned Katello::DockerMetaTag records.

foreman-rake console
Katello::DockerMetaTag.where("id not in (?)", Katello::RepositoryDockerMetaTag.pluck(:docker_meta_tag_id)).size
exit

4. It should return 0 records.
5. Remove the CCV version 1 and wait until the task is finished.
6. Repeat step 3, and you will see some orphaned Katello::DockerMetaTag records.

Additional info:
To fix the "ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint" error, we can run the following commands to remove the orphaned Katello::DockerMetaTag records

NOTE: For security, please make a snapshot of the Satellite before proceeding.

foreman-rake console
Katello::DockerMetaTag.where("id not in (?)", Katello::RepositoryDockerMetaTag.pluck(:docker_meta_tag_id)).delete_all
exit

Actions #1

Updated by Hao Yu almost 4 years ago

  • Priority changed from Normal to Low
Actions #2

Updated by John Mitsch almost 4 years ago

  • Target version set to Katello 4.0.0
  • Triaged changed from No to Yes
Actions #3

Updated by Chris Roberts over 3 years ago

  • Target version changed from Katello 4.0.0 to Katello 3.17.0
Actions #4

Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Samir Jha
  • Pull request https://github.com/Katello/katello/pull/8910 added
Actions #5

Updated by The Foreman Bot over 3 years ago

  • Fixed in Releases Katello 4.0.0 added
Actions #6

Updated by Samir Jha over 3 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF