Bug 1911753

Summary: dnf history undo not working
Product: [Fedora] Fedora Reporter: Robbi Nespu <robbinespu>
Component: dnfAssignee: Jaroslav Rohel <jrohel>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 33CC: dmach, jmracek, jrohel, mblaha, mhatina, packaging-team-maint, pkratoch, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-04 13:05:50 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:

Description Robbi Nespu 2020-12-31 01:48:04 UTC
Description of problem:
Undo transaction cannot be carry out by dnf

Version-Release number of selected component (if applicable):

$ dnf info dnf
Last metadata expiration check: 0:16:26 ago on Thu 31 Dec 2020 09:25:29 AM +08.
Installed Packages
Name         : dnf
Version      : 4.5.2
Release      : 1.fc33
Architecture : noarch
Size         : 2.0 M
Source       : dnf-4.5.2-1.fc33.src.rpm
Repository   : @System
From repo    : updates-testing
Summary      : Package manager
URL          : https://github.com/rpm-software-management/dnf
License      : GPLv2+
Description  : Utility that allows users to manage packages on their systems.
             : It supports RPMs, modules and comps groups & environments.

How reproducible:

Steps to Reproduce:
1. dnf update icecat
2. dnf history undo last

Actual results:
$ sudo dnf history undo last
[sudo] password for robbi:
Last metadata expiration check: 0:24:35 ago on Thu 31 Dec 2020 09:18:49 AM +08.
Undoing transaction 15, from Thu 31 Dec 2020 09:31:29 AM +08
    Upgrade  icecat-78.6.0-2.rh1.fc33.x86_64 @updates
    Upgraded icecat-78.5.0-2.rh2.fc33.x86_64 @@System
No package icecat-78.5.0-2.rh2.fc33.x86_64 available.
Error: no package matched

Expected results:
DNF should able to undo / downgrade icecat package back to 78.5.0-2.rh2.fc33

Additional info:
dnf history info 15
Transaction ID : 15
Begin time     : Thu 31 Dec 2020 09:31:29 AM +08
Begin rpmdb    : 1448:392d27370be7608526fcef0475d4bee78ebffc22
End time       : Thu 31 Dec 2020 09:31:47 AM +08 (18 seconds)
End rpmdb      : 1448:46959b33ef3c9604fe74ec6a98b5d13771f73f3b
User           : robbi <robbi>
Return-Code    : Success
Releasever     : 33
Command Line   : update icecat
Comment        :
Packages Altered:
    Upgrade  icecat-78.6.0-2.rh1.fc33.x86_64 @updates
    Upgraded icecat-78.5.0-2.rh2.fc33.x86_64 @@System

Comment 1 Jaroslav Rohel 2021-01-04 07:42:18 UTC
DNF is right. DNF wants to downgrade the "icecat" package back. However,  the "icecat-78.5.0-2.rh2.fc33.x86_64" package is not available in the repositories.

How it can happen?
Packages in the "updates" repository are frequently updated and older packages are removed over time. Probably the "icecat-78.5.0-2.rh2.fc33.x86_64" package was in the "updates" repository some time ago. Your system had been updated to it. Later, updated package "icecat-78.6.0-2.rh1.fc33.x86_64" came to the "updates" repository. The older package "icecat-78.5.0-2.rh2.fc33.x86_64" was removed from the "updates" repository after some time. The "icecat" package was updated on your system again. You want to perform "undo". However, the "icecat-78.5.0-2.rh2.fc33.x86_64" package is not available in the repositories. Therefore, no package matched to the DNF request and DNF generate error message "Error: no package matched".

Comment 2 Daniel Mach 2021-01-04 12:42:38 UTC
There's a upstream PR on improving the history command:

It's probably not going to fix the issue completely (the root cause is an unavailable package),
but the new behaviour could be better. There is going to be an option to skip missing packages.