Bug 2013320

Summary: CV publish fails with "get() returned more than one UpdateRecord" if multiple advisories with the same errata_id are requested to be published
Product: Red Hat Satellite Reporter: Tanya Tereshchenko <ttereshc>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10.0CC: ahumbe, ggainey, iballou, jbhatia, jhutar, jsenkyri, myarboro, osousa, pmendezh, rchan, ttereshc, zhunting
Target Milestone: 6.10.1Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-18 14:38:46 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:
Bug Depends On:    
Bug Blocks: 2000289    

Description Tanya Tereshchenko 2021-10-12 15:11:08 UTC
Description of problem:
CV publish fails if it happen to contain multiple advisories with the same errata_id but different otherwise.

Version-Release number of selected component (if applicable):
6.10.0 snap 22


Steps to Reproduce (copied from BZ#1986356#c1, since QE ran into this issue using those steps, see BZ#1986356#c41)
- sync a repo (e.g. RH SCL, not a huge one but big enough to see the sequential activity that can be paralelised)
- create several CVs with that repo, e.g. with include filters (just to differentiate the CVs, not required, though); below are hammer commands for it (repo id is 4, customise it if required):

 content-view create --name CV_SCL_filter_no_include_2020-01-01 --organization-id=1 --repository-ids=4 --solve-dependencies=no
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-01-01 --name=include_base --inclusion=true --original-packages=true --type=rpm
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-01-01 --name=include_errata --inclusion=true --type=erratum
 content-view filter rule create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-01-01 --content-view-filter=include_errata --date-type='updated' --end-date='2020-01-01'
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-01-01 --name=include_modules --inclusion=true --original-module-streams=true --type=modulemd
 content-view create --name CV_SCL_filter_no_include_2020-04-01 --organization-id=1 --repository-ids=4 --solve-dependencies=no
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-04-01 --name=include_base --inclusion=true --original-packages=true --type=rpm
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-04-01 --name=include_errata --inclusion=true --type=erratum
 content-view filter rule create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-04-01 --content-view-filter=include_errata --date-type='updated' --end-date='2020-04-01'
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-04-01 --name=include_modules --inclusion=true --original-module-streams=true --type=modulemd
 content-view create --name CV_SCL_filter_no_include_2020-07-01 --organization-id=1 --repository-ids=4 --solve-dependencies=no
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-07-01 --name=include_base --inclusion=true --original-packages=true --type=rpm
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-07-01 --name=include_errata --inclusion=true --type=erratum
 content-view filter rule create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-07-01 --content-view-filter=include_errata --date-type='updated' --end-date='2020-07-01'
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-07-01 --name=include_modules --inclusion=true --original-module-streams=true --type=modulemd
 content-view create --name CV_SCL_filter_no_include_2020-10-01 --organization-id=1 --repository-ids=4 --solve-dependencies=no
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-10-01 --name=include_base --inclusion=true --original-packages=true --type=rpm
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-10-01 --name=include_errata --inclusion=true --type=erratum
 content-view filter rule create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-10-01 --content-view-filter=include_errata --date-type='updated' --end-date='2020-10-01'
 content-view filter create --organization-id=1 --content-view=CV_SCL_filter_no_include_2020-10-01 --name=include_modules --inclusion=true --original-module-streams=true --type=modulemd
 content-view publish --name=CV_SCL_filter_no_include_2020-01-01 --organization-id=1 --async
 content-view publish --name=CV_SCL_filter_no_include_2020-04-01 --organization-id=1 --async
 content-view publish --name=CV_SCL_filter_no_include_2020-07-01 --organization-id=1 --async
 content-view publish --name=CV_SCL_filter_no_include_2020-10-01 --organization-id=1 --async


Actual results:
Errors with "get() returned more than one UpdateRecord -- it returned 2!`"

pulp [59cc0e4d-b1d3-4e83-be25-a010e9413044]: pulpcore.tasking.pulpcore_worker:INFO: Task 1584fe74-28d1-4d63-9710-b1b4e36a6e1c failed (get() returned more than one UpdateRecord -- it returned 2!) 
pulp [59cc0e4d-b1d3-4e83-be25-a010e9413044]: pulpcore.tasking.pulpcore_worker:INFO:   File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 317, in _perform_task
result = func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/repository.py", line 219, in add_and_remove
new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
File "/usr/lib/python3.6/site-packages/pulpcore/app/models/repository.py", line 963, in __exit__
repository.finalize_new_version(self)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/models/repository.py", line 353, in finalize_new_version
resolve_advisories(new_version, previous_version)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/advisory.py", line 87, in resolve_advisories
previous_advisory = previous_advisories.get(id=advisory_id)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 412, in get
(self.model._meta.object_name, num)


pulp [59cc0e4d-b1d3-4e83-be25-a010e9413044]: pulpcore.tasking.pulpcore_worker:INFO: Task e9a64af6-047f-48d6-825d-48108e9e3c26 failed (get() returned more than one UpdateRecord -- it returned 2!) 
pulp [59cc0e4d-b1d3-4e83-be25-a010e9413044]: pulpcore.tasking.pulpcore_worker:INFO:   File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 317, in _perform_task
result = func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/repository.py", line 219, in add_and_remove
new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
File "/usr/lib/python3.6/site-packages/pulpcore/app/models/repository.py", line 963, in __exit__
repository.finalize_new_version(self)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/models/repository.py", line 353, in finalize_new_version
resolve_advisories(new_version, previous_version)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/advisory.py", line 88, in resolve_advisories
added_advisory = UpdateRecord.objects.get(id=advisory_id, pk__in=added_advisory_pks)
File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 412, in get
(self.model._meta.object_name, num)



Expected results:
No errors


Additional info:
See related convo BZ#1986356#c41

Comment 2 pulp-infra@redhat.com 2021-10-12 16:11:26 UTC
The Pulp upstream bug status is at ASSIGNED. Updating the external tracker on this bug.

Comment 3 pulp-infra@redhat.com 2021-10-12 16:11:27 UTC
The Pulp upstream bug priority is at Normal. Updating the external tracker on this bug.

Comment 6 pulp-infra@redhat.com 2021-10-13 22:08:13 UTC
The Pulp upstream bug status is at POST. Updating the external tracker on this bug.

Comment 7 mark yarborough 2021-10-14 14:52:36 UTC
Please include in 6.10.1

Comment 9 Brad Buckingham 2021-10-14 16:39:21 UTC
Removed the foreman redmine (https://projects.theforeman.org/issues/33648) as that fix is being tracked with bug 2011528.

Comment 10 Tanya Tereshchenko 2021-10-19 12:07:27 UTC
Fixed in the upstream pulp_rpm 3.14.7

Comment 11 pulp-infra@redhat.com 2021-10-19 12:12:51 UTC
The Pulp upstream bug status is at CLOSED - CURRENTRELEASE. Updating the external tracker on this bug.

Comment 12 pulp-infra@redhat.com 2021-10-19 12:12:52 UTC
The Pulp upstream bug priority is at Normal. Updating the external tracker on this bug.

Comment 13 pulp-infra@redhat.com 2021-10-19 13:20:39 UTC
All upstream Pulp bugs are at MODIFIED+. Moving this bug to POST.

Comment 18 Lai 2021-11-10 16:31:02 UTC
I followed the description for retesting.


Publishing the cv returns successfully and no more errors showed up.

Verified on 6.10.1_01

Comment 20 Jan Hutaƙ 2021-11-12 08:39:29 UTC
*** Bug 2018888 has been marked as a duplicate of this bug. ***

Comment 25 errata-xmlrpc 2021-11-18 14:38:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Satellite 6.10.1 Async Bug Fix Update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4737