Project

General

Profile

Bug #25774

sometimes RHEL8 Beta sync fails: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_module_stream_artifacts_name_mod_stream_id_uniq"

Added by John Mitsch 8 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Repositories
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

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

Description of problem:
sometimes RHEL8 Beta sync fails: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_module_stream_artifacts_name_mod_stream_id_uniq"

Version-Release number of selected component (if applicable):
Katello 3.10

How reproducible:
sometimes

Steps to Reproduce:
1. I have started sync of these 4 repos:
Content -> Sync Status
Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta Kickstart
Red Hat Enterprise Linux 8 for x86_64 - BaseOS Beta RPMs
Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta Kickstart
Red Hat Enterprise Linux 8 for x86_64 - AppStream Beta RPMs
2. Other than that I have also same set of HTB repos enabled (but have not synced it yet)

Actual results:
One of sync tasks fails with warning:

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_module_stream_artifacts_name_mod_stream_id_uniq"
DETAIL: Key (module_stream_id, name)=(1, rust-doc-0:1.26.2-12.el8+2011+e949f8f2.x86_64) already exists.
: INSERT INTO "katello_module_stream_artifacts" ("module_stream_id", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"

When I rerun sync on that single repo, it works.

Expected results:
Should work on a first try

Associated revisions

Revision 55ab5479 (diff)
Added by John Mitsch 8 months ago

Fixes #25774 - Handle uniq errors when importing mod stream

I believe the associated bug is a race condition because I can't
reproduce it syncing the same repos. If this is a race condition, the
active_record_retry method will help prevent errors by rescuing the
unique errors raised and retrying the transaction.

I also updated the tests to create multiple records for profiles
and artifacts. It also looks like the tests weren't working as
intended previously, they should be fixed now.

History

#1 Updated by John Mitsch 8 months ago

  • Description updated (diff)

#2 Updated by The Foreman Bot 8 months ago

  • Assignee set to John Mitsch
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/7909 added

#3 Updated by John Mitsch 8 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Jonathon Turel 8 months ago

  • Triaged changed from No to Yes
  • Target version set to Katello 3.11.0

Also available in: Atom PDF