Bug 2077864

Summary: "dnf download" does not randomly redownload a broken package
Product: Red Hat Enterprise Linux 8 Reporter: Eva Mrakova <emrakova>
Component: librepoAssignee: amatej
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: medium Docs Contact: Mariya Pershina <mpershin>
Priority: medium    
Version: 8.7CC: amatej, james.antill, mbanas, packaging-team-maint, ppisar, swm-qe
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: librepo-1.14.2-2.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 2077859 Environment:
Last Closed: 2022-11-08 10:54:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 1 Petr Pisar 2022-04-25 11:58:29 UTC
I can reproduce it RHEL 9.0 and RHEL 8.6. But it does not manifests in Fedora 37 and Fedora 34. Because DNF stack in RHEL 9.0 is newer that Fedora's one, I suspect this could be a bug in Linux kernel. Kernel in RHEL 9 is older than in Fedora.

Comment 2 amatej 2022-04-26 06:52:47 UTC
I managed to reproduce it even on fedora.

I am pretty sure the problem is that since https://github.com/rpm-software-management/dnf/pull/1743 dnf uses librepo for checksum checking which uses caching.

Basically dnf downloads the package and stores (caches) its checksum and mtime to xattrs of the file then when the computer is fast enough (only sometimes) it rewrites the file with "blah" in the same mtime. On the next run dnf compares the file mtime with cached mtime and since they match it uses the cached (wrong) checksum -> no redownload.

To workaround this you can:
2. for i in {1..10}; do echo blah > bash-5.1.8-4.el9.x86_64.rpm ; dnf download bash; sleep 1s; done

Comment 4 amatej 2022-05-05 10:49:52 UTC
I have created a PR that should resolve this: https://github.com/rpm-software-management/librepo/pull/256

Comment 5 amatej 2022-05-10 10:35:53 UTC
PR with CI tests: https://github.com/rpm-software-management/ci-dnf-stack/pull/1096

Comment 13 errata-xmlrpc 2022-11-08 10:54:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (librepo bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7780