help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/var/guix/db/db.sqlite corruption


From: Mike Gerwitz
Subject: /var/guix/db/db.sqlite corruption
Date: Fri, 02 Aug 2019 21:36:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

A while back, I ran out of disk space while running `guix package -i`,
during a build.  I then noticed that `guix gc` would, after outputting
some number of "deleting" lines, fail with an error that's approximately
this (I forgot to make a copy):

  guix gc: error: executing SQLite query: malformed database image

This error appears to come from nix/libstore/sqlite.cc, and the last
portion of the message comes from `sqlite3_errmsg`, so I don't think
this is Guix's fault.

I had already run e2fsck on many occasions since this happened a couple
months back and there are no disk errors.

To work around it, I dumped the DB:

  $ sqlite3 db.sqlite .dump > ~/bak.sql

The final line of that file contains this:

  ROLLBACK; -- due to errors

Understandable.  I replaced that with "COMMIT;", and:

  $ mv db.sqlite{,-bak}
  $ sqlite3 db.sqlite < ~/bak.sql

This produced a database that was 4MiB smaller than the original. :x
But now `guix gc` works.[*]

So my questions are:

  - Is there a way to regenerate the database?
  - What bad things could happen with what I just did?

Thanks, and please nobody reading this message in a list archive in the
future do the above without first reading replies to this thread; I
don't want to be responsible for anything bad that may result! :)

[*]: Actually, I had some other bizarre issues.  After I recreated the
DB, I started getting more generic I/O errors.  There were no errors in
dmesg.  But when I moved the file to a different location (e.g. my home
directory), it worked (via `sqlite3`).  If I moved it back to
`/var/guix/db/db.sqlite`, I/O errors once again.  If I ran `.dump` from
that dir, empty.  If I moved it to my home dir and ran `.dump`, I got
the full dump.  This problem didn't resolve until after a reboot.  I
haven't seen anything like that before, and I don't want to
speculate.  I should have tried flushing the kernel I/O cache before
rebooting to see if that would have fixed it.

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]