Bug 2096161

Summary: "duplicate key value violates unique constraint \"core_repositorycontent_repository_id_content_id_fb06c181_uniq
Product: Red Hat Satellite Reporter: Vedashree Deshpande <vdeshpan>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.10.6CC: sajha, satellite6-bugs
Target Milestone: UnspecifiedKeywords: Regression
Target Release: UnusedFlags: vdeshpan: needinfo? (satellite6-bugs)
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vedashree Deshpande 2022-06-13 06:43:47 UTC
Description of problem:
When publishing new CV version, task fails with error from $subject


Errors:
duplicate key value violates unique constraint "core_repositorycontent_repository_id_content_id_fb06c181_uniq"
DETAIL:  Key (repository_id, content_id, version_added_id)=(ea9a371f-a0d0-49fb-8015-e8ff0d7386ec, a35a6e2e-6322-4df5-bacf-c08c31cdb223, 0071580e-9146-4d9f-a9c5-15088dab5594) already exists.
duplicate key value violates unique constraint "core_repositorycontent_repository_id_content_id_fb06c181_uniq"
DETAIL:  Key (repository_id, content_id, version_added_id)=(81dc2b7a-ede1-4f9f-a73e-43e401456b11, 12f82b48-86bb-459d-b012-2b7899b8cafd, 0d4a504b-0655-4315-ab0b-28fc6d176686) already exists.


Version-Release number of selected component (if applicable):
satellite-6.10.6-1.el7sat.noarch
satellite-installer-6.10.0.7-1.el7sat.noarch
satellite-cli-6.10.6-1.el7sat.noarch
satellite-common-6.10.6-1.el7sat.noarch
satellite-maintain-0.0.1-1.el7sat.noarch

How reproducible:


Steps to Reproduce:
Steps:
1) Create a content view and attach "Red Hat Satellite Tools 6.10 for RHEL 7 Server RPMs x86_64" repo.
2) Create a package include filter.
3) In the package filter:
   a) Add 2 rules to include 'foreman-cli' and 'katello-agent' rpms.

4) Publish the content view. CV version 1.0 should have the following 2 rpms:

  - foreman-cli
  - katello-agent

5) Amend the package filter:
  a) Add 1 rule to include 'katello-host-tools' rpm.

6) Publish the content view again. CV version 2.0 should have the following 3 rpms:

  - foreman-cli
  - katello-agent
  - katello-host-tools

7) Amend the package filter:
   a) Remove 2 rules that included 'foreman-cli' and 'katello-agent'.
   b) Add 1 rule to include 'katello-host-tools-fact-plugin' rpm.

8) Publish the content view again. CV version 3.0 should have the following 2 rpms:

  - katello-host-tools
  - katello-host-tools-fact-plugin

9) Amend the package filter:
  a) Add 2 rules to include 'foreman-cli' and 'katello-agent' rpms. 

10) Publish the content view again. CV version 4.0 should have the following 4 rpms:

  - foreman-cli
  - katello-agent
  - katello-host-tools
  - katello-host-tools-fact-plugin


11) Manually trigger a clean orphan task. Wait until the task is finished in Web UI -> Monitor -> Task page.

foreman-rake katello:delete_orphaned_content

12) Amend the package filter:
  a) Remove 2 rules that included 'foreman-cli' and 'katello-agent'.


13) Tail the /var/log/messages file

tail -f /var/log/messages


14) Publish the content view again.