Subject: Re: bug#36687: guix gc: error: executing SQLite statement: database disk image is malformed

From: Chris Marusich <[email-masked]>
Date: Thu, 18 Jul 2019 22:30:11 -0700

Ricardo Wurmus <[email-masked]> writes:

> Chris Marusich <[email-masked]> writes:
>
>> My disk was filling up, so I tried to run "guix gc", but I got an error
>> instead:
>>
>> --8<---------------cut here---------------start------------->8---
>> $ guix gc -C 25GiB
>> ...
>> deleting `/gnu/store/n0gyzfw77ik35ld9d0d4737w88f11m4b-profile.drv'
>> deleting `/gnu/store/fl7w0dlki7c906isiiflf9ka4c49zcmi-ca-certificate-bundle.drv'
>> deleting `/gnu/store/ipn4xvvb3wrbx4lhzwdyyylvj42vyg6f-xdg-desktop-database.drv'
>> guix gc: error: executing SQLite statement: database disk image is malformed
>> --8<---------------cut here---------------end--------------->8---
>>
>> What does this mean?
>
> I think this means that the database has been corrupted.

I ran it a second time.  It printed more messages, but curiously it
errored out after saying that it deleted another
xdg-desktop-database.drv:

--8<---------------cut here---------------start------------->8---
$ guix gc -C 25GiB
...
deleting `/gnu/store/d5z2lazx11qz571mwy59gwlqxidj0h4r-gtk-im-modules.drv'
deleting `/gnu/store/gc36aax38fs194ll5s17j8a8l8arm09a-gtk-icon-themes.drv'
deleting `/gnu/store/hbxvgm2pc6f6jn2fai30izc7f5kd25qd-gtk-im-modules.drv'
deleting `/gnu/store/hrc7yacy4ckmp3zi5pgmzd5ciqzv40ih-xdg-desktop-database.drv'
guix gc: error: executing SQLite statement: database disk image is malformed
--8<---------------cut here---------------end--------------->8---

I ran it a third time, and it printed:

--8<---------------cut here---------------start------------->8---
$ guix gc -C 25GiB
finding garbage collector roots...
deleting garbage...
deleting `/gnu/store/1dqflkm3029ncacx5vl9r95ldfcfs3m0-pugixml-1.9.drv'
guix gc: error: executing SQLite statement: database disk image is malformed
--8<---------------cut here---------------end--------------->8---

I ran it a fourth time, and it printed:

--8<---------------cut here---------------start------------->8---
$ guix gc -C 25GiB
...
deleting `/gnu/store/w0nbsjjb1pj9pi1aim1qcbjq93zss9pn-libwpd-0.10.2.drv'
deleting `/gnu/store/ywdgn73h9kdfcvs6cr1nfjqqj245p788-librevenge-0.0.4.drv'
deleting `/gnu/store/ryawkapgxirj6yp54zb5vak027xxk2i1-cppunit-1.14.0.drv'
deleting `/gnu/store/g2p20iss1r58r4ch2qggzyqn9d5q4kaf-cppunit-1.14.0.tar.gz.drv'
guix gc: error: executing SQLite statement: database disk image is malformed
--8<---------------cut here---------------end--------------->8---

I wonder what has brought my installation into this state.  I can't
think of a way to fix it since I don't even know what caused it, so I
will probably re-install Guix to work around the issue, but before I do
that, is there anything we can check to understand why the database
corruption has occurred?

For the record, I do sometimes abruptly power off my machine, and it
does rarely abruptly crash (I think I have reported this when it occurs,
but I can't be sure).  In such cases, when booting, I see messages
telling me that the system is recovering the journal from my ext4 file
system, and I do not recall ever seeing an error from that process, but
who knows what mischief I've been causing to my system over the years.

-- 
Chris