After upgrade to 4.3.1: "duplicate key value violates unique constraint" during content proxy sync

Problem:

I have upgraded my production system (katello server, puppet proxy, content proxy) from 3.1.3/4.2.1 to 3.2.1/4.3.1. Now each time I run a complete sync I get an error like this:

duplicate key value violates unique constraint "core_repositoryversion_repository_id_number_3c54ce50_uniq"
DETAIL:  Key (repository_id, number)=(74f3e561-ef72-4495-8b74-0d2b91ab87fe, 2) already exists.

I ran it twice during the last hour and I get exactly the same error message.

I have also tried yesterday, directly after the upgrade of the content proxy and I have got a different id (yes, twice in a single run):

duplicate key value violates unique constraint "core_repositoryversion_repository_id_number_3c54ce50_uniq"
DETAIL:  Key (repository_id, number)=(ac46caa8-0b8b-4da6-bcb0-e2e40ec77e19, 12) already exists.
duplicate key value violates unique constraint "core_repositoryversion_repository_id_number_3c54ce50_uniq"
DETAIL:  Key (repository_id, number)=(ac46caa8-0b8b-4da6-bcb0-e2e40ec77e19, 12) already exists.

New content has been synced and new content versions have been published since yesterday, so I suspect that’s why it looks different today.

The automatic, optimized sync after the cv promotion during the night was successful.

Expected outcome:
Successful sync.

Versions:
3.2.1/4.3.1 upgraded from 3.1.3/4.2.1.

Distribution and version:
CentOS 7.9 up-to-date

Is a distinct issue at all from Sync errors on all syncs including the initial sync between new katello server and content proxy or is it the same?

Just checking if the discussion should stay in one place.

@gvde ^^

@drallay You are absolutely right. I have even mentioned the second error there. 74f3e561 is CentOS Stream 8 BaseOS and ac46caa8 is AlmaLinx 8 BaseOS. It’s the same issue.

To be continued in Sync errors on all syncs including the initial sync between new katello server and content proxy