Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

historydb: Prevent insertion of duplicate group packages #1798

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Oct 23, 2024

When a package is included in a comps group multiple times, dnf5
attempts to insert that package multiple times into the
comps_group_package table of the transaction history database. However,
the table enforces a unique constraint on the (group_id, name_id) tuple.
This results in terminating dnf5 process.

This patch modifies the CompsGroupPackageDbUtils::comps_group_packages_insert()
method to track which packages have already been inserted and skip
duplicates.

Here is an example of such group with duplicated packages from rpmfusion
repository (see the libavcodec-freeworld package):

<group>
  <id>multimedia</id>
  <name>Multimedia</name>
  <description>Audio/video framework common to desktops</description>
  <default>false</default>
  <uservisible>false</uservisible>
  <packagelist>
    <packagereq>gstreamer1-plugins-bad-freeworld</packagereq>
    <packagereq>gstreamer1-plugins-ugly</packagereq>
    <packagereq type="conditional" requires="chromium">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="firefox">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="libavcodec-free">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="libheif">libheif-freeworld</packagereq>
    <packagereq type="conditional" requires="pipewire">pipewire-codec-aptx</packagereq>
    <packagereq type="conditional" requires="qt5-qtwebengine">qt5-qtwebengine-freeworld</packagereq>
    <packagereq type="conditional" requires="vlc-libs">vlc-plugins-freeworld</packagereq>
  </packagelist>
</group>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2263762
Test: rpm-software-management/ci-dnf-stack#1580

When a package is included in a comps group multiple times, dnf5
attempts to insert that package multiple times into the
`comps_group_package table` of the transaction history database. However,
the table enforces a unique constraint on the (group_id, name_id) tuple.
This results in terminating dnf5 process.

This patch modifies the CompsGroupPackageDbUtils::comps_group_packages_insert()
method to track which packages have already been inserted and skip
duplicates.

Here is an example of such group with duplicated packages from rpmfusion
repository (see the `libavcodec-freeworld` package):

<group>
  <id>multimedia</id>
  <name>Multimedia</name>
  <description>Audio/video framework common to desktops</description>
  <default>false</default>
  <uservisible>false</uservisible>
  <packagelist>
    <packagereq>gstreamer1-plugins-bad-freeworld</packagereq>
    <packagereq>gstreamer1-plugins-ugly</packagereq>
    <packagereq type="conditional" requires="chromium">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="firefox">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="libavcodec-free">libavcodec-freeworld</packagereq>
    <packagereq type="conditional" requires="libheif">libheif-freeworld</packagereq>
    <packagereq type="conditional" requires="pipewire">pipewire-codec-aptx</packagereq>
    <packagereq type="conditional" requires="qt5-qtwebengine">qt5-qtwebengine-freeworld</packagereq>
    <packagereq type="conditional" requires="vlc-libs">vlc-plugins-freeworld</packagereq>
  </packagelist>
</group>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2263762
Copy link
Contributor

@ppisar ppisar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm it fixes the SQL constraint violation and the it fixes installing multimedia group of rpmfusion-free repository.

@ppisar ppisar added this pull request to the merge queue Oct 24, 2024
Merged via the queue into main with commit 47bd21d Oct 24, 2024
20 checks passed
@ppisar ppisar deleted the mblaha/sql-error branch October 24, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants