Skip to content

Multi-Repository Copy Fails with IntegrityError #4286

@guylain-lavoie

Description

@guylain-lavoie

Hello, here is another issue I have encountered while trying to perform a copy from several source repository in a single command.

Version
pulp_rpm 3.34.0
pulpcore 3.102.0
Container: docker.io/pulp/pulp (build 20260119)

Describe the bug

pulp rpm copy --dependency-solving with multiple source repositories targeting the same destination fails with:
IntegrityError: duplicate key value violates unique constraint "core_repositoryversion_repository_id_number_3c54ce50_uniq"
DETAIL: Key (repository_id, number)=(xxx, 1) already exists.

This occurs even with a package that has no dependencies (tzdata), so the issue is not dependency resolution — it seems to be a race condition when multiple config entries target the same dest_repo.

To Reproduce
Rsync AlmaLinux 10.0 repositories locally:

mkdir -p /mnt/repos/almalinux/10.0/{BaseOS,AppStream,CRB}/x86_64_v2/os

for repo in BaseOS AppStream CRB; do
    rsync -avz `--progress` \
        rsync://rsync.vault.almalinux.org/almalinux-vault/10.0/$repo/x86_64_v2/os/ \
        /mnt/repos/almalinux/10.0/$repo/x86_64_v2/os/
done

Create remotes with streamed policy:

bashpulp rpm remote create --name alma10-0-baseos \
    --url file:///mnt/repos/almalinux/10.0/BaseOS/x86_64_v2/os/ --policy streamed
pulp rpm remote create --name alma10-0-appstream \
    --url file:///mnt/repos/almalinux/10.0/AppStream/x86_64_v2/os/ --policy streamed
pulp rpm remote create --name alma10-0-crb \
    --url file:///mnt/repos/almalinux/10.0/CRB/x86_64_v2/os/ --policy streamed

Create and sync repositories:

bashfor repo in baseos appstream crb; do
    pulp rpm repository create --name alma10-0-$repo --remote alma10-0-$repo
    pulp rpm repository sync --name alma10-0-$repo
done

Create destination repository and get HREFs:

pulp rpm repository create --name my-private-repo

BASEOS_VER=$(pulp rpm repository show --name alma10-0-baseos | jq -r '.latest_version_href')
APPSTREAM_VER=$(pulp rpm repository show --name alma10-0-appstream | jq -r '.latest_version_href')
CRB_VER=$(pulp rpm repository show --name alma10-0-crb | jq -r '.latest_version_href')
DEST=$(pulp rpm repository show --name my-private-repo | jq -r '.pulp_href')

# Use tzdata - a package with NO dependencies
TZDATA=$(pulp rpm repository content -t package list --repository alma10-0-baseos --limit 10000 \
    | jq -r '.[] | select(.name=="tzdata") | .pulp_href' | head -1)

Attempt multi-repository copy:

cat > /tmp/copy-config.json << EOF
[
  {"source_repo_version": "$BASEOS_VER", "dest_repo": "$DEST", "content": ["$TZDATA"]},
  {"source_repo_version": "$APPSTREAM_VER", "dest_repo": "$DEST", "content": []},
  {"source_repo_version": "$CRB_VER", "dest_repo": "$DEST", "content": []}
]
EOF

pulp rpm copy --config @/tmp/copy-config.json --dependency-solving

Expected behavior
Multi-repo copy should work if copying just a single package without any dependencies.

Additional context
A work around that I found is to sync to a single repository from the many remotes and then copy from that repository to our private repository to manage exactly the packages we need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions