Bug 2142689

Summary: Capsule sync fails when a CV is published and promoted to two capsule's LCEs at the same time
Product: Red Hat Satellite Reporter: Vladimír Sedmík <vsedmik>
Component: Capsule - ContentAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.12.0CC: ahumbe, sajha
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
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: 2023-07-27 09:56:24 UTC 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 Vladimír Sedmík 2022-11-14 21:47:51 UTC
Description of problem:
Assume we have a Capsule which is assigned with Library and one another LCE. When we create a new CV with some repo and publish and promote it to the LCE, two sync tasks are triggered for each environment, but one of them fails due to duplicity error.
This might be a corner case worthless of any attention, but since we allow users to publish and promote CVs at the same time via WebUI, it seems to be not so difficult to hit.


Version-Release number of selected component (if applicable):
6.12.0
6.11.4


How reproducible:
always


Steps to Reproduce:
1) have a fresh SAT and CAPS (on_demand, no LCE added yet), create an organization, upload manifest
2) enable some mid-size repo (i.e. rhel-7-server-kickstart) and sync it
3) create new LCE, add it to the capsule together with the Library
4) create new CV, add the repo from 2), publish and promote it to the LCE from 3) -> two capsule sync tasks are triggered, one for Library and one for the new LCE. The first task succeeds, the second one fails. 


Actual results:
Task fails with error:
duplicate key value violates unique constraint "core_repositoryversion_repository_id_number_3c54ce50_uniq"
DETAIL:  Key (repository_id, number)=(fc310174-5f54-4ccc-8495-15f4b1de55a1, 1) already exists.
Could not lookup a publication_href for repo 4


Expected results:
Both tasks should succeed.