Database disk image is malformed in

I am getting the following traceback when trying to update my system:

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 191, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 65, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 98, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 122, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 158, in resolving
    base.resolve(cli.demands.allow_erasing)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 753, in resolve
    self._transaction = self._goal2transaction(goal)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 674, in _goal2transaction
    ts.add_upgrade(pkg, upgraded, obs)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 278, in add_upgrade
    ti_new = self.new(new, libdnf.transaction.TransactionItemAction_UPGRADE)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 227, in new
    reason = self.get_reason(pkg)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 242, in get_reason
    return self.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1)
  File "/usr/lib64/python3.7/site-packages/libdnf/transaction.py", line 792, in resolveRPMTransactionItemReason
    return _transaction.Swdb_resolveRPMTransactionItemReason(self, name, arch, maxTransactionId)
RuntimeError: Step: database disk image is malformed in

        SELECT
            ti.action as action,
            ti.reason as reason
        FROM
            trans_item ti
        JOIN
            trans t ON ti.trans_id = t.id
        JOIN
            rpm i USING (item_id)
        WHERE
            t.state = 1
            /* see comment in TransactionItem.hpp - TransactionItemAction */
            AND ti.action not in (3, 5, 7, 10)
            AND i.name = 'pcre2'
            AND i.arch = 'i686'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1

I’ve visited a few sites which tell to do this:

yum clean dbcache 

And above command also doesn’t solve the problem, this:

yum clean all
yum clean metadata
yum clean dbcache
yum makecache

Both the methods have not worked out for me. I was planning to upgrade to 31 after the update.

The reason maybe full out of space in root /, check it.

This is a well know ISSUE, reported before in RedHat Bugzilla:

https://bugzilla.redhat.com/show_bug.cgi?id=1669824#c7 , dumping and undumping
https://bugzilla.redhat.com/show_bug.cgi?id=1198998#c1 , clean dnf

Regards.,

I might have stumbled upon those tickets already while researching. But the problem doesn’t seem to be of disk space.

Removing the history SQLite file forces in creation of a new file. This solves the problem.

rm /var/lib/dnf/history.sqlite

You might consider renaming/backup it instead in case of failure.

3 Likes