Bug 2073061 - dnf upgrade: Error: SQLite error on "/var/lib/dnf/history.sqlite": Reading a row failed: UNIQUE constraint failed: rpm.name, rpm.epoch, rpm.version, rpm.release, rpm.arch
Summary: dnf upgrade: Error: SQLite error on "/var/lib/dnf/history.sqlite": Reading a ...
Keywords:
Status: CLOSED DUPLICATE of bug 1868860
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 36
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Lukáš Hrázký
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-04-07 15:01 UTC by Matti Linnanvuori
Modified: 2022-04-26 09:27 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-04-26 09:27:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Matti Linnanvuori 2022-04-07 15:01:33 UTC
Description of problem:
dnf --refresh upgrade fails with the following error.

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

How reproducible:
Run dnf --refresh upgrade

Steps to Reproduce:
1. Install Fedora Workstation 35
2. Upgrade to Fedora Workstation 36 Beta
3. Run dnf --refresh upgrade

Actual results:
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: SQLite error on "/var/lib/dnf/history.sqlite": Reading a row failed: UNIQUE constraint failed: rpm.name, rpm.epoch, rpm.version, rpm.release, rpm.arch

Expected results:
Running dnf --refresh upgrade succeeds.

Comment 1 Lukáš Hrázký 2022-04-26 09:27:32 UTC
Hello, apologies for the inconvenience. We're getting these reports quite rarely, they are nondeterministic (unless you can reproduce this, a reproducer would be very helpful to us) and we don't know the cause.

You can remove (or, better, back up and remove) the /var/lib/dnf/history.sqlite file, dnf will keep working but you'll lose your userinstalled / groupinstalled packages, meaning dnf will no longer know which packages you installed explicitly and which were pulled in as a dependency.

You can also attempt to repair the corrupted database following these steps (under root, you may need to install the sqlite3 binary via `dnf install -y sqlite`):
# cd /var/lib/dnf
# ls
history.sqlite  history.sqlite-shm  history.sqlite-wal  repos
# mkdir db-backup
# mv history.sqlite* db-backup
# echo .recover | sqlite3 db-backup/history.sqlite > recover.sql
# sqlite3 history.sqlite < recover.sql

I'm marking this as a duplicate as we already have a bug for this.

*** This bug has been marked as a duplicate of bug 1868860 ***


Note You need to log in before you can comment on or make changes to this bug.