Project

Profile

Help

Issue #9503

closed

get() returned more than one UpdateRecord -- it returned X!

Added by ttereshc about 3 years ago. Updated about 3 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Katello
Sprint:
Quarter:

Description

Advisory conflict resolution doesn't properly support the case when multiple advisories with the same errata_id but different in some other way are added to a repository version or somehow existed in previous repo version.

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)

Currently, there is a check for adding exactly the same advisory multiple times. It doesn't cover the case when it's different versions of the same advisory.

So it is possible to fail here when two different advisories but with the same errata_id are being added.

To reproduce, use modify/ endpoint and pass two different advisories with the same errata_id.


Related issues

Copied to RPM Support - Backport #9519: Backport #9503 "get() returned more than one UpdateRecord -- it returned X!" to 3.14.zCLOSED - CURRENTRELEASEttereshc

Actions
Actions #1

Updated by iballou about 3 years ago

Here's how I could see this happening in Katello:

In our copy code, we choose which errata to copy, and then copy over all of the errata's RepositoryErratums. A RepositoryErratum links an Erratum to repositories and Pulp 3 hrefs. (https://github.com/Katello/katello/blob/master/app/services/katello/pulp3/repository/yum.rb#L377)

Let's say there are two repositories that share an erratum, and only one is synced. There will be one Erratum and one RepositoryErratum in the DB. Now, the erratum is updated in the upstream repos. The first repo is not synced again, and the other repo is synced. Now, there is still one Erratum, but two RepositoryErratums. One RepositoryErratum points to the old Pulp 3 advisory, and the other points to the new Pulp 3 advisory that was created when the upstream erratum was edited.

In the copy code, we'll select the one Erratum, and then pluck all of the Pulp 3 advisory hrefs from the Erratum's RepositoryErratums. That would include two versions of the same erratum.

Actions #2

Updated by ttereshc about 3 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to ttereshc
Actions #3

Updated by ttereshc about 3 years ago

  • Tags Katello added
Actions #4

Updated by ttereshc about 3 years ago

  • Description updated (diff)
Actions #5

Updated by pulpbot about 3 years ago

  • Status changed from ASSIGNED to POST

Added by ttereshc about 3 years ago

Revision d519d9ab | View on GitHub

Advisory conflict resolution fixes.

closes #9503 https://pulp.plan.io/issues/9503

Actions #6

Updated by ttereshc about 3 years ago

  • Status changed from POST to MODIFIED
Actions #7

Updated by ttereshc about 3 years ago

  • Copied to Backport #9519: Backport #9503 "get() returned more than one UpdateRecord -- it returned X!" to 3.14.z added
Actions #9

Updated by pulpbot about 3 years ago

  • Sprint/Milestone set to 3.16.0
Actions #10

Updated by pulpbot about 3 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF