Bug 1941206

Summary: No access to rpm package database after upgrade from f32 to f34 with `dnf system-upgrade`
Product: [Fedora] Fedora Reporter: Wolfgang Ulbrich <raveit65.sun>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED WORKSFORME QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 34CC: igor.raits, mjw, packaging-team-maint, pmatilai, pmoravco, prd-fedora, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-03-23 08:49:06 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:
Attachments:
Description Flags
dnf.log 1
none
next log
none
next log 2
none
next log 3 none

Description Wolfgang Ulbrich 2021-03-20 20:37:33 UTC
Created attachment 1764933 [details]
dnf.log 1

Description of problem:
No access to rpm package database after upgrade from f32 to f34 with `dnf system-upgrade`

Version-Release number of selected component (if applicable):
[root@mother rave]# rpm -qa rpm
rpm-4.16.1.2-6.fc34.x86_64

How reproducible:
Upgrading f32 to f34 via dnf system-upgrade

Steps to Reproduce:
1.start dnf system-upgrade from f32
2.boot into f34 after upgrade
3. try to use dnf or rpm command

Actual results:

warning: Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
Running transaction check
warning: Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
RPM: warning: Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
RPM: error: cannot open Packages index using bdb_ro - Operation not permitted (1)
RPM: error: cannot open Packages database in /var/lib/rpm
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Could not run transaction.

Expected results:

no problems

Additional info:

`rpm --rebuilddb` fixes the problem

Comment 1 Wolfgang Ulbrich 2021-03-20 20:38:43 UTC
Created attachment 1764935 [details]
next log

Comment 2 Wolfgang Ulbrich 2021-03-20 20:39:34 UTC
Created attachment 1764936 [details]
next log 2

Comment 3 Wolfgang Ulbrich 2021-03-20 20:40:12 UTC
Created attachment 1764937 [details]
next log 3

Comment 4 Panu Matilainen 2021-03-22 08:22:13 UTC
The database is supposed to be converted (see https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb) in the upgrade process, but various things can of course go wrong. Likely victim of bug 1461313, see also bug 1836108.

This ought to clear it, if not then we'll need to investigate further:
# restorecon -v /var/lib/rpm/Packages
# rpmdb --rebuilddb

Comment 5 Wolfgang Ulbrich 2021-03-22 12:43:34 UTC
I simply followed those steps to upgrade f32 to f34 (system with selinux disabled):

dnf upgrade --refresh
dnf install dnf-plugin-system-upgrade
dnf system-upgrade download --refresh --releasever=34
dnf system-upgrade reboot

After the upgrade was done i did run in this issue.
And i had to rebuild rpm package database with `rpm --rebuilddb`.

Well, i was very surprised that this was needed and i expect that this can be done at the end of the upgrade process automatic, or not?

I can test it again with a f32 VM to verify the issue.

Comment 6 Panu Matilainen 2021-03-22 13:22:46 UTC
As I said in my initial response, it's supposed to be handled automatically by the upgrade process, but as with anything, things can go wrong. By far the most common issue has been selinux related problems, but there could be others.

The important thing is that you got the db converted in the end, chasing down an isolated failure doesn't warrant a whole lot of effort. But as a basic sanity check, what does the following say on that system: 

    systemctl status rpmdb-rebuild

Comment 7 Wolfgang Ulbrich 2021-03-22 20:56:33 UTC
OK,

[root@mother rave]# systemctl status rpmdb-rebuild
○ rpmdb-rebuild.service - RPM database rebuild
     Loaded: loaded (/usr/lib/systemd/system/rpmdb-rebuild.service; disabled; vendor preset: enabled)
     Active: inactive (dead)

Comment 8 Wolfgang Ulbrich 2021-03-22 21:08:39 UTC
Updating a f32 VM to f34 was successful and here the rpm database isn't broken.
Also the message is different.

[root@f32-test rave]# systemctl status rpmdb-rebuild
○ rpmdb-rebuild.service - RPM database rebuild
     Loaded: loaded (/usr/lib/systemd/system/rpmdb-rebuild.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Mon 2021-03-22 21:38:35 CET; 24min ago
    Process: 705 ExecStart=/usr/bin/rpmdb --rebuilddb (code=exited, status=0/SUCCESS)
    Process: 707 ExecStartPost=rm -f /var/lib/rpm/.rebuilddb (code=exited, status=0/SUCCESS)
   Main PID: 705 (code=exited, status=0/SUCCESS)
        CPU: 1.269s

Mär 22 21:38:33 f32-test.mother.loc systemd[1]: Starting RPM database rebuild...
Mär 22 21:38:33 f32-test.mother.loc rpmdb[705]: Warnung: Converting database from bdb_ro to sqlite backend
Mär 22 21:38:35 f32-test.mother.loc systemd[1]: rpmdb-rebuild.service: Deactivated successfully.
Mär 22 21:38:35 f32-test.mother.loc systemd[1]: Finished RPM database rebuild.
Mär 22 21:38:35 f32-test.mother.loc systemd[1]: rpmdb-rebuild.service: Consumed 1.269s CPU time.

Anyway, it seems it was only a one-shot and i know what to do when it happens again with another system.
So feel free to close the report.
Thanks for your analyse.

Comment 9 Wolfgang Ulbrich 2021-03-22 23:45:29 UTC
Hmm, now i am getting this problem when using mock build server for building my rpm.
How can i fix this inside mock?

Comment 10 Panu Matilainen 2021-03-23 08:49:06 UTC
With mock, you'll want to use --use-bootstrap-image whenever building for a different distro version.

Closing as per above comments, if this becomes more of a pattern then we'll need to investigate. Thanks for the report anyway!