Satellite tasks for Content Host profile uploads end in Warnings due to Unique Constraint violations
Environment
Red Hat Satellite 6.7 (likely earlierversions as well, but the specific tasks may differ)
Issue
Actions::Katello::Host::UploadProfilestasks end with aWarningresult.- During the Run phase of the task, it errors with a Unique Constraint violation on
katello_content_facet_repository_rid_caid
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "katello_content_facet_repository_rid_caid"
DETAIL: Key (repository_id, content_facet_id)=(123456, 654321) already exists.
: INSERT INTO "katello_content_facet_repositories" ("content_facet_id", "repository_id") VALUES ($1, $2) RETURNING "id"
Resolution
So far the problem only occurred when an initial capsule sync was being attempted, and the UploadProfiles tasks stopped encountering issues once the initial sync completed.
For more KB articles/solutions related to Red Hat Satellite 6.x Satellite Tasking System Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Satellite Tasking System Issues
Root Cause
This is believed to be a timing issue wherein two separate unrelated tasks are attempting to insert into the postgres foreman database that would violate the required uniqueness, in this case of a database Index.
In the observed case of the Actions::Katello::Host::UploadProfiles task, it is trying to import values relating to which repositories are enabled for a Content Host. In the observed occurrence, a very slow running Capsule sync was also in progress, which was attempting to update some of the same repository IDs.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.