Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1677774 - dnf aborts trying to remove some packages
Summary: dnf aborts trying to remove some packages
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 31
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
Assignee: Lukáš Hrázký
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-15 20:33 UTC by Kevin Fenzi
Modified: 2020-04-18 00:06 UTC (History)
12 users (show)

Fixed In Version: dnf-4.2.21-1.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-18 00:06:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
dnf history sqlite database (2.78 MB, application/x-xz)
2019-12-13 14:26 UTC, Paolo
no flags Details

Description Kevin Fenzi 2019-02-15 20:33:52 UTC
➜  ~ sudo dnf remove gofed-infra gofed-gofedlib gofed gofed-resources 
terminate called after throwing an instance of 'SQLite3::LibException'
  what():  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 = 'dbus-libs'
            AND i.arch = 'x86_64'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1
    
Happy to gather more info, but might rpm -e these packages to move forward.

Comment 1 Marek Blaha 2019-02-18 12:42:43 UTC
Are you able to provide full traceback / coredump? And which versions of dnf/libdnf are you using?

Comment 2 Kevin Fenzi 2019-02-18 17:24:52 UTC
➜  ~ rpm -q dnf python3
dnf-4.1.0-1.fc30.noarch
python3-3.7.2-6.fc30.x86_64

           PID: 8479 (dnf)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 6 (ABRT)
     Timestamp: Mon 2019-02-18 09:22:36 PST (1min 11s ago)                                               
  Command Line: /usr/bin/python3 /usr/bin/dnf remove f25-backgrounds-25.1.1-7.fc30.noarch                
    Executable: /usr/bin/python3.7
 Control Group: /user.slice/user-1000.slice/user/dbus\x2d:1.2\x2dcom.gexperts.Tilix.slice/dbus-:1.2-com.gexperts.Tilix
          Unit: user
     User Unit: dbus-:1.2-com.gexperts.Tilix                                                   
         Slice: user-1000.slice
     Owner UID: 1000 (kevin)
       Boot ID: 11072d611b8447159c57e65ec89f0e15
    Machine ID: 54945dc7fd0a438f9f0a0a4e162d5983
      Hostname: taim.scrye.com
       Storage: /var/lib/systemd/coredump/core.dnf.0.11072d611b8447159c57e65ec89f0e15.8479.1550510556000000.lz4 (inaccessible)
       Message: Process 8479 (dnf) of user 0 dumped core.                                                

                Stack trace of thread 8479:
                #0  0x00007f50932980f5 raise (libc.so.6)
                #1  0x00007f5093282895 abort (libc.so.6)
                #2  0x00007f508511567a n/a (libstdc++.so.6)
                #3  0x00007f508512159c n/a (libstdc++.so.6)
                #4  0x00007f50851215f7 _ZSt9terminatev (libstdc++.so.6)
                #5  0x00007f5085121859 __cxa_throw (libstdc++.so.6)
                #6  0x00007f50852e44b8 n/a (libdnf.so.2)
                #7  0x00007f50853387c5 _ZNK6libdnf4Swdb19filterUserinstalledERNS_10PackageSetE (libdnf.so.2)
                #8  0x00007f508251fcf0 n/a (_hawkey.so)
                #9  0x00007f5093025958 _PyMethodDef_RawFastCallKeywords (libpython3.7m.so.1.0)
                #10 0x00007f50930641ad _PyMethodDescr_FastCallKeywords (libpython3.7m.so.1.0)
                #11 0x00007f509306432b n/a (libpython3.7m.so.1.0)
                #12 0x00007f50930aa529 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #13 0x00007f509304d472 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #14 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #15 0x00007f50930aa529 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #16 0x00007f509304c5f0 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #17 0x00007f509304d610 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #18 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #19 0x00007f50930aa529 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #20 0x00007f509304d472 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #21 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #22 0x00007f50930aa482 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #23 0x00007f509304d472 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #24 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #25 0x00007f50930aa482 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #26 0x00007f509304d472 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #27 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #28 0x00007f50930aa482 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #29 0x00007f509304c5f0 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #30 0x00007f509304d610 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #31 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #32 0x00007f50930aa482 _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #33 0x00007f509304c5f0 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #34 0x00007f509304d610 _PyFunction_FastCallKeywords (libpython3.7m.so.1.0)
                #35 0x00007f509306425f n/a (libpython3.7m.so.1.0)
                #36 0x00007f50930ab31f _PyEval_EvalFrameDefault (libpython3.7m.so.1.0)
                #37 0x00007f509304c5f0 _PyEval_EvalCodeWithName (libpython3.7m.so.1.0)
                #38 0x00007f509304d349 PyEval_EvalCodeEx (libpython3.7m.so.1.0)
                #39 0x00007f509304d36b PyEval_EvalCode (libpython3.7m.so.1.0)
                #40 0x00007f5093114e23 n/a (libpython3.7m.so.1.0)
                #41 0x00007f50931150e7 PyRun_FileExFlags (libpython3.7m.so.1.0)
                #42 0x00007f509311a6e6 PyRun_SimpleFileExFlags (libpython3.7m.so.1.0)
                #43 0x00007f509311c39c n/a (libpython3.7m.so.1.0)
                #44 0x00007f509311c54c _Py_UnixMain (libpython3.7m.so.1.0)
                #45 0x00007f5093283f33 __libc_start_main (libc.so.6)
                #46 0x0000556a212d708e _start (python3.7)

This happens on every 'dnf remove' 

I guess my history has some entry for 'dbus-libs thats causing it to blow up?

Comment 3 Daniel Mach 2019-02-25 12:28:23 UTC
Kevin,
we'll work on a recovery mechanism dealing with a broken db.
The question is what is the root cause.
By any chance, didn't the host run out of disk space during?
It seems like corrupted sqlite db because of that.

Comment 4 Jaroslav Mracek 2019-07-04 06:59:25 UTC
Please could you reproduce the issue with the latest libdnf/dnf from our nightly repository? Just use "dnf copr enable rpmsoftwaremanagement/dnf-nightly".

Comment 5 Kevin Fenzi 2019-07-04 17:56:44 UTC
Sadly, I rebuilt that machine, so I no longer can debug the issue. ;(

Comment 6 Paolo 2019-07-18 16:12:33 UTC
Hi, I'm having the same issue, though the package causing it is gnome-autoar and not dbus-libs on my box.
I've tried rebuilding the db with `rpm --rebuilddb` but didn't help. If I manually remove gnome-autoar with `rpm -e gnome-autoar --nodeps`
then `dnf remove` works, but as soon I reinstall gnome-autoar the same issue arise.

$ rpm -q dnf python3
dnf-4.2.8-0.41g27b7a927.fc30.noarch
python3-3.7.3-3.fc30.x86_64

$ sudo dnf remove gimp
terminate called after throwing an instance of 'SQLite3::LibException'
  what():  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 = 'gnome-autoar'
            AND i.arch = 'x86_64'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1
    
Aborted


And the backtrace:
#0  0x00007ffff7de0e75 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7dcb895 in __GI_abort () at abort.c:79
#2  0x00007fffe9db46da in __gnu_cxx::__verbose_terminate_handler() ()
    at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007fffe9dc061c in __cxxabiv1::__terminate(void (*)()) (handler=<optimized out>)
    at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x00007fffe9dc0677 in std::terminate() () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:57
#5  0x00007fffe9dc08d9 in __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))
    (obj=obj@entry=0x555555b1b600, tinfo=tinfo@entry=0x7fffe9bf1e40 <typeinfo for SQLite3::LibException>, dest=dest@entry=0x7fffe9b10be0 <SQLite3::LibException::~LibException()>) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:95
#6  0x00007fffe9acdd5a in SQLite3::Statement::step() (this=0x7fffffffc1f0)
    at /usr/include/c++/9/ext/new_allocator.h:89
#7  0x00007fffe9acdd5a in libdnf::RPMItem::resolveTransactionItemReason(std::shared_ptr<SQLite3>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long)                                                                        
    (conn=std::shared_ptr<class SQLite3> (use count 3, weak count 0) = {...}, name="gnome-autoar", arch="x86_64", maxTransactionId=maxTransactionId@entry=-1)
    at /usr/src/debug/libdnf-0.35.2-0.16g5208ec9c.fc30.x86_64/libdnf/transaction/RPMItem.cpp:283
#8  0x00007fffe9b25385 in libdnf::Swdb::filterUserinstalled(libdnf::PackageSet&) const
    (this=0x555555b1b480, installed=...) at /usr/include/c++/9/ext/atomicity.h:96
#9  0x00007fffe7d50e50 in  () at /usr/lib64/python3.7/site-packages/hawkey/_hawkey.so
#10 0x00007ffff7b6b968 in _PyMethodDef_RawFastCallKeywords
    (method=<optimized out>, self=<_hawkey.Query at remote 0x7fffe768b1b0>, args=<optimized out>, nargs=<optimized out>, kwnames=0x0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:690
#11 0x00007ffff7ba3e9d in _PyMethodDescr_FastCallKeywords
    (descrobj=<method_descriptor at remote 0x7fffe7d8a288>, args=0x7fffe76441e0, nargs=2, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/descrobject.c:288
#12 0x00007ffff7ba402b in call_function (pp_stack=0x7fffffffc5d0, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4593
#13 0x00007ffff7be1ae5 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3110
#14 0x00007ffff7b90e82 in function_code_fastcall
    (globals=<optimized out>, nargs=3, args=<optimized out>, co=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#15 0x00007ffff7b90e82 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x7fffe76bf3f8, nargs=3, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#16 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffc7d0, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#17 0x00007ffff7be1ae5 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3110
#18 0x00007ffff7b90000 in _PyEval_EvalCodeWithName
    (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=0x0, kwargs=0x555555adf6d0, kwcount=<optimized out>, kwstep=1, defs=0x7fffea097e60, defcount=1, kwdefs=0x0, closure=0x0, name='resolve', qualname='Base.resolve')
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3930
#19 0x00007ffff7b91022 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x555555adf6c0, nargs=2, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:433
#20 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffcac0, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#21 0x00007ffff7be1ae5 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3110
#22 0x00007ffff7b90e82 in function_code_fastcall
    (globals=<optimized out>, nargs=2, args=<optimized out>, co=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#23 0x00007ffff7b90e82 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x555555ac7de0, nargs=2, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#24 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffccc8, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#25 0x00007ffff7be1a40 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3124
#26 0x00007ffff7b90e82 in function_code_fastcall
    (globals=<optimized out>, nargs=2, args=<optimized out>, co=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#27 0x00007ffff7b90e82 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x5555555c7bd8, nargs=2, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#28 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffcec8, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#29 0x00007ffff7be1a40 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3124
#30 0x00007ffff7b90e82 in function_code_fastcall
    (globals=<optimized out>, nargs=4, args=<optimized out>, co=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#31 0x00007ffff7b90e82 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x555555599fc0, nargs=4, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:408
#32 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffd0c8, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#33 0x00007ffff7be1a40 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3124
#34 0x00007ffff7b90000 in _PyEval_EvalCodeWithName
    (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=0x0, kwargs=0x555555967568, kwcount=<optimized out>, kwstep=1, defs=0x7fffe7b88a38, defcount=3, kwdefs=0x0, closure=0x0, name='main', qualname='main') at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3930
#35 0x00007ffff7b91022 in _PyFunction_FastCallKeywords
    (func=<optimized out>, stack=0x555555967560, nargs=1, kwnames=<optimized out>)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:433
#36 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffd3b8, oparg=<optimized out>, kwnames=0x0)
    at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#37 0x00007ffff7be1a40 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3124
#38 0x00007ffff7b90000 in _PyEval_EvalCodeWithName (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=0x7fffea7ec5d8, kwargs=0x7fffea926b70, kwcount=<optimized out>, kwstep=1, defs=0x7fffe7a232c8, defcount=1, kwdefs=0x0, closure=0x0, name='user_main', qualname='user_main') at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3930
#39 0x00007ffff7b91022 in _PyFunction_FastCallKeywords (func=<optimized out>, stack=0x7fffea926b68, nargs=1, kwnames=<optimized out>) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Objects/call.c:433
#40 0x00007ffff7ba3f4f in call_function (pp_stack=0x7fffffffd6b0, oparg=<optimized out>, kwnames=('exit_code',)) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:4616
#41 0x00007ffff7be28e9 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3139
#42 0x00007ffff7b90000 in _PyEval_EvalCodeWithName (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=0x0, kwargs=0x0, kwcount=<optimized out>, kwstep=2, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3930
#43 0x00007ffff7b90d59 in PyEval_EvalCodeEx (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kws=<optimized out>, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:3959
#44 0x00007ffff7b90d7b in PyEval_EvalCode (co=co@entry=<code at remote 0x7fffea7ff540>, globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}, locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/ceval.c:524
#45 0x00007ffff7c5d093 in run_mod (mod=<optimized out>, filename=<optimized out>, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}, locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}, flags=<optimized out>, arena=<optimized out>) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/pythonrun.c:1035
#46 0x00007ffff7c5d3f7 in PyRun_FileExFlags (fp=0x55555559ffa0, filename_str=<optimized out>, start=<optimized out>, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}, locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/usr/bin/dnf') at remote 0x7fffea8a9da0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff7fbbc28>, '__file__': '/usr/bin/dnf', '__cached__': None, 'unicode_literals': <_Feature(optional=(2, 6, 0, 'alpha', 2), mandatory=(3, 0, 0, 'alpha', 0), compiler_flag=131072) at remote 0x7fffea7450b8>, 'sys': <module at remote 0x7ffff7fb5f98>, 'suppress_keyboard_interrupt_message': <function at remote 0x7fffea8e4268>, 'here': '/usr/bin', 'main': <module at remote 0x7fffe7bfb4a8>}, closeit=1, flags=0x7fffffffd990) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/pythonrun.c:988
#47 0x00007ffff7c630aa in PyRun_SimpleFileExFlags (fp=0x55555559ffa0, filename=<optimized out>, closeit=1, flags=0x7fffffffd990) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Python/pythonrun.c:429
#48 0x00007ffff7c64d9c in pymain_run_file (p_cf=0x7fffffffd990, filename=<optimized out>, fp=0x55555559ffa0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Modules/main.c:427
#49 0x00007ffff7c64d9c in pymain_run_filename (cf=0x7fffffffd990, pymain=0x7fffffffdaa0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Modules/main.c:1627
#50 0x00007ffff7c64d9c in pymain_run_python (pymain=0x7fffffffdaa0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Modules/main.c:2877
#51 0x00007ffff7c64d9c in pymain_main (pymain=0x7fffffffdaa0) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Modules/main.c:3038
#52 0x00007ffff7c64f4c in _Py_UnixMain (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/python3-3.7.3-3.fc30.x86_64/Modules/main.c:3073
#53 0x00007ffff7dccf33 in __libc_start_main (main=0x555555555050 <main>, argc=4, argv=0x7fffffffdbf8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdbe8) at ../csu/libc-start.c:308
#54 0x000055555555508e in _start ()

Comment 7 Paolo 2019-07-18 16:33:09 UTC
Having a look with strace seems the issue lies within the history.sqlite db.
Cleaning it makes `dnf remove` working again, though I have a backup of the old one if someone needs any info.

Comment 8 Ben Cotton 2019-08-13 17:03:50 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 9 Ben Cotton 2019-08-13 18:56:52 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to 31.

Comment 10 Lukáš Hrázký 2019-12-13 13:40:12 UTC
Hello Paolo, sorry for a late response. Do you happen to still have that corrupted file?

Comment 11 Paolo 2019-12-13 14:26:42 UTC
Created attachment 1644871 [details]
dnf history sqlite database

Comment 12 Paolo 2019-12-13 14:28:21 UTC
I do!
Just attached it, I have a backup of the whole /var/lib/dnf folder if you need other files as well, let me know.

Comment 13 Lukáš Hrázký 2019-12-13 16:20:09 UTC
Nice, I reproduced it. Thanks a lot!

Comment 14 kaveh 2019-12-30 18:38:33 UTC
Hi, I am on fedora 29 and was trying to upgrade to 30 when I got this error. I thought it was because of vscode package ( package name code ) so I tried to uninstall that. got the same error. removed it with "rpm", and removed the microsoft repository. But I am still getting this error. here is a full copy paste of my terminal content:


 
[root@kaveh-pc ~]# dnf update -y
Adobe Systems Incorporated                                                                         9.3 kB/s | 2.9 kB     00:00    
Docker CE Stable - x86_64                                                                           17 kB/s | 3.5 kB     00:00    
Fedora Modular 29 - x86_64                                                                          29 kB/s |  17 kB     00:00    
Fedora Modular 29 - x86_64 - Updates                                                                63 kB/s |  16 kB     00:00    
Fedora 29 - x86_64 - Updates                                                                        72 kB/s |  17 kB     00:00    
Fedora 29 - x86_64                                                                                  19 kB/s |  17 kB     00:00    
google-chrome                                                                                       11 kB/s | 1.3 kB     00:00    
Google Cloud SDK                                                                                   519  B/s | 454  B     00:00    
MySQL 8.0 Community Server                                                                          13 kB/s | 2.5 kB     00:00    
MySQL Connectors Community                                                                          14 kB/s | 2.5 kB     00:00    
MySQL Tools Community                                                                              9.1 kB/s | 2.5 kB     00:00    
RPM Fusion for Fedora 29 - Free - Updates                                                          2.8 kB/s | 3.0 kB     00:01    
RPM Fusion for Fedora 29 - Free                                                                    4.3 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 29 - Nonfree - Updates                                                       4.1 kB/s | 3.0 kB     00:00    
RPM Fusion for Fedora 29 - Nonfree                                                                 4.2 kB/s | 3.2 kB     00:00    
Sublime Text - x86_64 - Stable                                                                     7.0 kB/s | 2.9 kB     00:00    
Visual Studio Code                                                                                 4.9 kB/s | 2.9 kB     00:00    
Dependencies resolved.
===================================================================================================================================
 Package                                       Architecture     Version                           Repository                  Size
===================================================================================================================================
Upgrading:
 google-chrome-stable                          x86_64           79.0.3945.88-1                    google-chrome               59 M
 google-cloud-sdk                              noarch           274.0.1-1                         google-cloud-sdk            37 M
 google-cloud-sdk-app-engine-python            noarch           274.0.1-1                         google-cloud-sdk           6.2 M
 google-cloud-sdk-datastore-emulator           noarch           274.0.1-1                         google-cloud-sdk            18 M
 google-cloud-sdk-pubsub-emulator              noarch           274.0.1-1                         google-cloud-sdk            35 M
 code                                          x86_64           1.41.1-1576681965.el7             code                        79 M

Transaction Summary
===================================================================================================================================
Upgrade  6 Packages

Total download size: 234 M
Downloading Packages:
(1/6): f03ed2e0f9eadb3a46564683464d4a8fbb48a1f5a5173fe1702931dad651433a-google-cloud-sdk-app-engin 746 kB/s | 6.2 MB     00:08    
(2/6): 4d2d6f2fef50ea6b4c083e933456d32d2f751c990bf41e1663ada61fa7619572-google-cloud-sdk-274.0.1-1 2.3 MB/s |  37 MB     00:16    
(3/6): google-chrome-stable-79.0.3945.88-1.x86_64.rpm                                              2.3 MB/s |  59 MB     00:25    
(4/6): 9b49a3bf890ce45c951a8962cb4c28cf32fd31629b2efffc9076807c0e61255f-google-cloud-sdk-datastore 1.0 MB/s |  18 MB     00:17    
(5/6): f11084550a41a19c7edb643225f49987780370eab2cc4084a01e092bf70190b5-google-cloud-sdk-pubsub-em 2.4 MB/s |  35 MB     00:14    
(6/6): code-1.41.1-1576681965.el7.x86_64.rpm                                                       2.3 MB/s |  79 MB     00:34    
-----------------------------------------------------------------------------------------------------------------------------------
Total                                                                                              3.9 MB/s | 234 MB     01:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                           1/1 
  Upgrading        : google-cloud-sdk-274.0.1-1.noarch                                                                        1/12 
  Running scriptlet: google-cloud-sdk-274.0.1-1.noarch                                                                        1/12 
  Upgrading        : google-cloud-sdk-app-engine-python-274.0.1-1.noarch                                                      2/12 
  Upgrading        : google-cloud-sdk-datastore-emulator-274.0.1-1.noarch                                                     3/12 
  Upgrading        : google-cloud-sdk-pubsub-emulator-274.0.1-1.noarch                                                        4/12 
  Upgrading        : code-1.41.1-1576681965.el7.x86_64                                                                        5/12 
  Running scriptlet: code-1.41.1-1576681965.el7.x86_64                                                                        5/12 
  Running scriptlet: google-chrome-stable-79.0.3945.88-1.x86_64                                                               6/12 
  Upgrading        : google-chrome-stable-79.0.3945.88-1.x86_64                                                               6/12 
  Running scriptlet: google-chrome-stable-79.0.3945.88-1.x86_64                                                               6/12 
Redirecting to /bin/systemctl start atd.service

  Cleanup          : google-cloud-sdk-pubsub-emulator-273.0.0-1.noarch                                                        7/12 
  Cleanup          : google-cloud-sdk-datastore-emulator-273.0.0-1.noarch                                                     8/12 
  Cleanup          : google-cloud-sdk-app-engine-python-273.0.0-1.noarch                                                      9/12 
  Running scriptlet: google-cloud-sdk-273.0.0-1.noarch                                                                       10/12 
  Cleanup          : google-cloud-sdk-273.0.0-1.noarch                                                                       10/12 
  Running scriptlet: google-cloud-sdk-273.0.0-1.noarch                                                                       10/12 
Compiling platform/bq/third_party/yaml/lib3/__init__.py ...
  File "platform/bq/third_party/yaml/lib3/__init__.py", line 284
    class YAMLObject(metaclass=YAMLObjectMetaclass):
                              ^
SyntaxError: invalid syntax


  Running scriptlet: google-chrome-stable-79.0.3945.79-1.x86_64                                                              11/12 
  Cleanup          : google-chrome-stable-79.0.3945.79-1.x86_64                                                              11/12 
  Running scriptlet: google-chrome-stable-79.0.3945.79-1.x86_64                                                              11/12 
  Cleanup          : code-1.41.0-1576089692.el7.x86_64                                                                       12/12 
  Running scriptlet: code-1.41.0-1576089692.el7.x86_64                                                                       12/12 
  Verifying        : google-chrome-stable-79.0.3945.88-1.x86_64                                                               1/12 
  Verifying        : google-chrome-stable-79.0.3945.79-1.x86_64                                                               2/12 
  Verifying        : google-cloud-sdk-274.0.1-1.noarch                                                                        3/12 
  Verifying        : google-cloud-sdk-273.0.0-1.noarch                                                                        4/12 
  Verifying        : google-cloud-sdk-app-engine-python-274.0.1-1.noarch                                                      5/12 
  Verifying        : google-cloud-sdk-app-engine-python-273.0.0-1.noarch                                                      6/12 
  Verifying        : google-cloud-sdk-datastore-emulator-274.0.1-1.noarch                                                     7/12 
  Verifying        : google-cloud-sdk-datastore-emulator-273.0.0-1.noarch                                                     8/12 
  Verifying        : google-cloud-sdk-pubsub-emulator-274.0.1-1.noarch                                                        9/12 
  Verifying        : google-cloud-sdk-pubsub-emulator-273.0.0-1.noarch                                                       10/12 
  Verifying        : code-1.41.1-1576681965.el7.x86_64                                                                       11/12 
  Verifying        : code-1.41.0-1576089692.el7.x86_64                                                                       12/12 

Upgraded:
  google-chrome-stable-79.0.3945.88-1.x86_64                      google-cloud-sdk-274.0.1-1.noarch                               
  google-cloud-sdk-app-engine-python-274.0.1-1.noarch             google-cloud-sdk-datastore-emulator-274.0.1-1.noarch            
  google-cloud-sdk-pubsub-emulator-274.0.1-1.noarch               code-1.41.1-1576681965.el7.x86_64                               

Complete!
[root@kaveh-pc ~]# cat /etc/os-release 
NAME=Fedora
VERSION="29 (Twenty Nine)"
ID=fedora
VERSION_ID=29
VERSION_CODENAME=""
PLATFORM_ID="platform:f29"
PRETTY_NAME="Fedora 29 (Twenty Nine)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:29"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f29/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=29
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=29
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
[root@kaveh-pc ~]# 
[root@kaveh-pc ~]# 
[root@kaveh-pc ~]# 
[root@kaveh-pc ~]# dnf system-upgrade download --releasever=30
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". Do you want to continue [y/N]: n
Error: Operation aborted.
[root@kaveh-pc ~]# dnf --refresh upgrade
Adobe Systems Incorporated                                                                         8.4 kB/s | 2.9 kB     00:00    
Docker CE Stable - x86_64                                                                           13 kB/s | 3.5 kB     00:00    
Fedora Modular 29 - x86_64                                                                          19 kB/s |  19 kB     00:00    
Fedora Modular 29 - x86_64 - Updates                                                                42 kB/s |  18 kB     00:00    
Fedora 29 - x86_64 - Updates                                                                        43 kB/s |  18 kB     00:00    
Fedora 29 - x86_64                                                                                  46 kB/s |  19 kB     00:00    
google-chrome                                                                                      7.2 kB/s | 1.3 kB     00:00    
Google Cloud SDK                                                                                   706  B/s | 454  B     00:00    
MySQL 8.0 Community Server                                                                          27 kB/s | 2.5 kB     00:00    
MySQL Connectors Community                                                                          51 kB/s | 2.5 kB     00:00    
MySQL Tools Community                                                                               49 kB/s | 2.5 kB     00:00    
RPM Fusion for Fedora 29 - Free - Updates                                                          2.9 kB/s | 3.0 kB     00:01    
RPM Fusion for Fedora 29 - Free                                                                    4.5 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 29 - Nonfree - Updates                                                       3.6 kB/s | 2.6 kB     00:00    
RPM Fusion for Fedora 29 - Nonfree                                                                 3.7 kB/s | 2.7 kB     00:00    
Sublime Text - x86_64 - Stable                                                                     6.3 kB/s | 2.9 kB     00:00    
Visual Studio Code                                                                                 4.3 kB/s | 2.9 kB     00:00    
Dependencies resolved.
Nothing to do.
Complete!
[root@kaveh-pc ~]# dnf system-upgrade download --releasever=30
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". Do you want to continue [y/N]: y
Adobe Systems Incorporated                                                                         9.6 kB/s | 2.0 kB     00:00    
Docker CE Stable - x86_64                                                                           15 kB/s | 7.5 kB     00:00    
Fedora Modular 30 - x86_64                                                                         689 kB/s | 1.9 MB     00:02    
Fedora Modular 30 - x86_64 - Updates                                                               662 kB/s | 3.5 MB     00:05    
Fedora 30 - x86_64 - Updates                                                                       645 kB/s |  27 MB     00:42    
Fedora 30 - x86_64                                                                                 1.1 MB/s |  61 MB     00:54    
google-chrome                                                                                       21 kB/s | 3.5 kB     00:00    
Google Cloud SDK                                                                                   547  B/s | 454  B     00:00    
Google Cloud SDK                                                                                    12 kB/s | 1.8 kB     00:00    
Importing GPG key 0xA7317B0F:
 Userid     : "Google Cloud Packages Automatic Signing Key <gc-team>"
 Fingerprint: D0BC 747F D8CA F711 7500 D6FA 3746 C208 A731 7B0F
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y
Importing GPG key 0xBA07F4FB:
 Userid     : "Google Cloud Packages Automatic Signing Key <gc-team>"
 Fingerprint: 54A6 47F9 048D 5688 D7DA 2ABE 6A03 0B21 BA07 F4FB
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y
Google Cloud SDK                                                                                   4.3 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Is this ok [y/N]: y
Google Cloud SDK                                                                                   3.8 MB/s |  29 MB     00:07    
MySQL 8.0 Community Server                                                                         2.0 MB/s | 589 kB     00:00    
MySQL Connectors Community                                                                         254 kB/s |  24 kB     00:00    
MySQL Tools Community                                                                              475 kB/s |  55 kB     00:00    
RPM Fusion for Fedora 30 - Free - Updates                                                          228 kB/s | 404 kB     00:01    
RPM Fusion for Fedora 30 - Free                                                                    390 kB/s | 735 kB     00:01    
RPM Fusion for Fedora 30 - Nonfree - Updates                                                        61 kB/s |  77 kB     00:01    
RPM Fusion for Fedora 30 - Nonfree                                                                 153 kB/s | 227 kB     00:01    
Sublime Text - x86_64 - Stable                                                                     2.6 kB/s | 2.0 kB     00:00    
Visual Studio Code                                                                                 1.0 MB/s | 2.6 MB     00:02    
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 192, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 123, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 159, in resolving
    base.resolve(cli.demands.allow_erasing)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 767, in resolve
    self._transaction = self._goal2transaction(goal)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 688, in _goal2transaction
    ts.add_upgrade(pkg, upgraded, obs)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 272, in add_upgrade
    ti_new = self.new(new, libdnf.transaction.TransactionItemAction_UPGRADE)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 225, in new
    reason = self.get_reason(pkg)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 240, in get_reason
    return self.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1)
  File "/usr/lib64/python3.7/site-packages/libdnf/transaction.py", line 788, 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 = 'python3-pam'
            AND i.arch = 'noarch'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1


[root@kaveh-pc ~]# rpm -qa | grep code
perl-Unicode-Normalize-1.26-417.fc29.x86_64
base64coder-20101219-22.fc29.noarch
unicode-ucd-12.1.0-1.fc29.noarch
perl-Encode-2.98-6.fc29.x86_64
code-1.41.1-1576681965.el7.x86_64
iso-codes-3.79-2.fc29.noarch
apache-commons-codec-1.11-4.fc29.noarch
python3-pycodestyle-2.4.0-3.fc29.noarch
ibus-rawcode-1.3.2-13.fc29.x86_64
dmidecode-3.2-1.fc29.x86_64
microcode_ctl-2.1-34.fc29.x86_64
qrencode-libs-3.4.4-6.fc29.x86_64
python3-dmidecode-3.12.2-13.fc29.x86_64
[root@kaveh-pc ~]# dnf remove code
terminate called after throwing an instance of 'SQLite3::LibException'
  what():  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 = 'python3-pam'
            AND i.arch = 'noarch'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1
    
Aborted (core dumped)
[root@kaveh-pc ~]# rpm -e code --nodeps
[root@kaveh-pc ~]# dnf remove code
No match for argument: code
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
[root@kaveh-pc ~]# cd /etc/yum.repos.d/
[root@kaveh-pc yum.repos.d]# ll
total 84
-rw-r--r--. 1 root root  183 Jan 16  2018 adobe-linux-x86_64.repo
-rw-r--r--. 1 root root 1892 Jan 16  2018 docker-ce.repo
-rw-r--r--. 1 root root  705 Aug 19 10:52 fedora-cisco-openh264.repo
-rw-r--r--. 1 root root 1395 Aug 19 10:52 fedora-modular.repo
-rw-r--r--. 1 root root 1331 Aug 19 10:52 fedora.repo
-rw-r--r--. 1 root root 1441 Aug 19 10:52 fedora-updates-modular.repo
-rw-r--r--. 1 root root 1378 Aug 19 10:52 fedora-updates.repo
-rw-r--r--. 1 root root 1483 Aug 19 10:52 fedora-updates-testing-modular.repo
-rw-r--r--. 1 root root 1436 Aug 19 10:52 fedora-updates-testing.repo
-rw-r--r--. 1 root root  173 Mar 29  2018 google-chrome.repo
-rw-r--r--. 1 root root  283 Nov 26  2018 google-cloud-sdk.repo
-rw-r--r--. 1 root root 1028 Jan 17  2019 mysql-community.repo
-rw-r--r--. 1 root root 1081 Jan 17  2019 mysql-community-source.repo
-rw-r--r--. 1 root root 1248 Oct 18  2018 rpmfusion-free.repo
-rw-r--r--. 1 root root 1264 Oct 18  2018 rpmfusion-free-updates.repo
-rw-r--r--. 1 root root 1324 Oct 18  2018 rpmfusion-free-updates-testing.repo
-rw-r--r--. 1 root root 1312 Oct 18  2018 rpmfusion-nonfree.repo
-rw-r--r--. 1 root root 1309 Oct 18  2018 rpmfusion-nonfree-updates.repo
-rw-r--r--. 1 root root 1369 Oct 18  2018 rpmfusion-nonfree-updates-testing.repo
-rw-r--r--. 1 root root  193 Jan 16  2018 sublime-text.repo
-rw-r--r--. 1 root root  165 Dec  6 11:00 vscode.repo
[root@kaveh-pc yum.repos.d]# cat vscode.repo 
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

[root@kaveh-pc yum.repos.d]# mv vscode.repo vscode.repo.not
[root@kaveh-pc yum.repos.d]# cd
[root@kaveh-pc ~]# dnf system-upgrade download --releasever=30
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". Do you want to continue [y/N]: y
Adobe Systems Incorporated                                                                                 9.6 kB/s | 2.9 kB     00:00    
Docker CE Stable - x86_64                                                                                   13 kB/s | 3.5 kB     00:00    
Fedora Modular 30 - x86_64                                                                                  20 kB/s |  19 kB     00:00    
Fedora Modular 30 - x86_64 - Updates                                                                        40 kB/s |  18 kB     00:00    
Fedora 30 - x86_64 - Updates                                                                                40 kB/s |  18 kB     00:00    
Fedora 30 - x86_64                                                                                          43 kB/s |  19 kB     00:00    
google-chrome                                                                                              7.2 kB/s | 1.3 kB     00:00    
Google Cloud SDK                                                                                           550  B/s | 454  B     00:00    
MySQL 8.0 Community Server                                                                                  36 kB/s | 2.5 kB     00:00    
MySQL Connectors Community                                                                                  57 kB/s | 2.5 kB     00:00    
MySQL Tools Community                                                                                       54 kB/s | 2.5 kB     00:00    
RPM Fusion for Fedora 30 - Free - Updates                                                                  3.0 kB/s | 3.2 kB     00:01    
RPM Fusion for Fedora 30 - Free                                                                            4.4 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree - Updates                                                               4.4 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree                                                                         3.8 kB/s | 2.7 kB     00:00    
Sublime Text - x86_64 - Stable                                                                             6.5 kB/s | 2.9 kB     00:00    
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 192, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 123, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 159, in resolving
    base.resolve(cli.demands.allow_erasing)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 767, in resolve
    self._transaction = self._goal2transaction(goal)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 688, in _goal2transaction
    ts.add_upgrade(pkg, upgraded, obs)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 272, in add_upgrade
    ti_new = self.new(new, libdnf.transaction.TransactionItemAction_UPGRADE)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 225, in new
    reason = self.get_reason(pkg)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 240, in get_reason
    return self.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1)
  File "/usr/lib64/python3.7/site-packages/libdnf/transaction.py", line 788, 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 = 'python3-pam'
            AND i.arch = 'noarch'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1
    
[root@kaveh-pc ~]# rpm --rebuilddb 
[root@kaveh-pc ~]# 
[root@kaveh-pc ~]# 
[root@kaveh-pc ~]# dnf system-upgrade download --releasever=30
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". Do you want to continue [y/N]: y
Adobe Systems Incorporated                                                                                  18 kB/s | 2.9 kB     00:00    
Docker CE Stable - x86_64                                                                                   15 kB/s | 3.5 kB     00:00    
Fedora Modular 30 - x86_64                                                                                  49 kB/s |  19 kB     00:00    
Fedora Modular 30 - x86_64 - Updates                                                                        84 kB/s |  18 kB     00:00    
Fedora 30 - x86_64 - Updates                                                                                86 kB/s |  18 kB     00:00    
Fedora 30 - x86_64                                                                                          93 kB/s |  19 kB     00:00    
google-chrome                                                                                               19 kB/s | 1.3 kB     00:00    
Google Cloud SDK                                                                                           646  B/s | 454  B     00:00    
MySQL 8.0 Community Server                                                                                  13 kB/s | 2.5 kB     00:00    
MySQL Connectors Community                                                                                  46 kB/s | 2.5 kB     00:00    
MySQL Tools Community                                                                                       47 kB/s | 2.5 kB     00:00    
RPM Fusion for Fedora 30 - Free - Updates                                                                  4.5 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 30 - Free                                                                            4.4 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree - Updates                                                               4.5 kB/s | 3.2 kB     00:00    
RPM Fusion for Fedora 30 - Nonfree                                                                         3.7 kB/s | 2.7 kB     00:00    
Sublime Text - x86_64 - Stable                                                                             7.5 kB/s | 2.9 kB     00:00    
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 192, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 123, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 159, in resolving
    base.resolve(cli.demands.allow_erasing)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 767, in resolve
    self._transaction = self._goal2transaction(goal)
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 688, in _goal2transaction
    ts.add_upgrade(pkg, upgraded, obs)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 272, in add_upgrade
    ti_new = self.new(new, libdnf.transaction.TransactionItemAction_UPGRADE)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 225, in new
    reason = self.get_reason(pkg)
  File "/usr/lib/python3.7/site-packages/dnf/db/group.py", line 240, in get_reason
    return self.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, -1)
  File "/usr/lib64/python3.7/site-packages/libdnf/transaction.py", line 788, 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 = 'python3-pam'
            AND i.arch = 'noarch'
        ORDER BY
            ti.trans_id DESC
        LIMIT 1
    
[root@kaveh-pc ~]#

Comment 15 Lukáš Hrázký 2020-01-02 09:23:27 UTC
Hello kaveh,

this issue is caused by corrupted SQLite database (that DNF uses to store the transaction history) at /var/lib/dnf/history.sqlite. The corruption must have occurred sometime earlier. Do you remember any power outages, hard reboots, crashes or running out of disk space?

If you don't care about your transaction history, you can just remove the above mentioned file (or back it up somewhere). DNF doesn't need it to run.

I've got patches for improving the error message, but unless the corruption is being caused by a bug in DNF (the number of reports we're getting hints more at random system failures), we probably can't do much more (apart from some clever logic around what to do when the DB is corrupted, which I'm not convinced we should do at all).

Comment 17 Lukáš Hrázký 2020-01-02 12:16:37 UTC
kaveh, I was unaware that the information which packages are user-installed (in other words, the packages you explicitly installed yourself) and also the installed groups (I think) is also stored in the history.sqlite database. So it's not just history you're losing by deleting the file. So better back it up somewhere, but since it's corrupted anyway, I don't think there's an easy way to retrieve the data from it.

Sorry about the inconvenience, it's a poor design choice on the DNF side, unfortunately.

Comment 18 kaveh 2020-01-02 18:24:31 UTC
Thanks. I don't remember an outages or anything like that. it could be just bit rot. Anyway I moved the history.sqlite* files to a backup folder, and now dnf seems to be happily upgrading to f30.

thanks again, and happy new year ;)

Comment 19 Lukáš Hrázký 2020-04-01 13:43:12 UTC
The error message was improved and the problem should now be reported properly to the user.

Comment 20 Fedora Update System 2020-04-02 12:50:10 UTC
FEDORA-2020-d51dbe83a9 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d51dbe83a9

Comment 21 Fedora Update System 2020-04-03 20:49:47 UTC
FEDORA-2020-d51dbe83a9 has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-d51dbe83a9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-d51dbe83a9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 22 Fedora Update System 2020-04-18 00:06:59 UTC
FEDORA-2020-d51dbe83a9 has been pushed to the Fedora 31 stable repository.
If problem still persists, please make note of it in this bug report.


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