I'm also getting this problem.
`guix gc --verify` doesn't fix it for me.
Here is the output for each of the commands you (Danny Milosavljevic) suggested:
$ cp /var/guix/db/db.sqlite /tmp/
$ sqlite3 /tmp/db.sqlite
sqlite> .tables
DerivationOutputs FailedPaths Refs ValidPaths
sqlite> .schema Refs
CREATE TABLE Refs (
referrer integer not null,
reference integer not null,
primary key (referrer, reference),
foreign key (referrer) references ValidPaths(id) on delete cascade,
foreign key (reference) references ValidPaths(id) on delete restrict
);
CREATE INDEX IndexReferrer on Refs(referrer);
CREATE INDEX IndexReference on Refs(reference);
sqlite> .schema DerivationOutputs
CREATE TABLE DerivationOutputs (
drv integer not null,
id text not null, -- symbolic output id, usually "out"
path text not null,
primary key (drv, id),
foreign key (drv) references ValidPaths(id) on delete cascade
);
CREATE INDEX IndexDerivationOutputs on DerivationOutputs(path);
sqlite> .schema FailedPaths
CREATE TABLE FailedPaths (
path text primary key not null,
time integer not null
);
sqlite> .schema ValidPaths
CREATE TABLE ValidPaths (
id integer primary key autoincrement not null,
path text unique not null,
hash text not null,
registrationTime integer not null,
deriver text,
narSize integer
);
CREATE TRIGGER DeleteSelfRefs before delete on ValidPaths
begin
delete from Refs where referrer = old.id and reference = old.id;
end;