Re: Correcting message references

Subject: Re: Correcting message references

Date: Tue, 25 Apr 2023 16:40:49 -0300

To: Al Haji-Ali,


From: David Bremner

David Bremner <> writes:

> Al Haji-Ali <> writes:
>> So it does seem to be a lingering ghost message, but I am sure that there are no messages in the database referring to this ID (except messages in this current thread which have the ID in the message body).
>> I don't know why this particular ID is associated to messages in another seemingly unrelated thread as you in the pdf.
>> Is there a way to remove this ghost message record somehow to test it? Or is there a better way of figuring this out.
> It turns out notmuch does not remove ghost messages until all the other
> messages in the thread are deleted. I guess if you temporarily move
> the other messages in the thread out of the way and run notmuch new, the
> ghost message should be deleted.
> I don't know how often this lazy deletion is a problem. Deleting
> messages is already a bottleneck in notmuch-new so I am a bit hesitant
> to make it more complicated. It is possible to "garbage collect"
> unreferenced ghost messages. I'll have to think about how big a
> performance hit it would be to add this to notmuch new.
> d

Here is a prototype standalone program to find lingering unreferenced
ghosts.  I find 33 (out of about 60k total ghost messages) in about 0.3s
on this laptop. Currently it does not modify the database, but the next
step would be to delete the documents rather than just printing them

If you have libxapian-dev (or equivalent) installed you can build it

$ c++ -o ggc -lxapian

and then run it

$ ./ggc ~/.local/share/notmuch/default/xapian

I would be interested if it finds your problematic ghost message (and
how long it takes).

notmuch mailing list --
To unsubscribe send an email to