Re: Notmuch and cross-posts, is my database corrupted?

Subject: Re: Notmuch and cross-posts, is my database corrupted?

Date: Fri, 28 Aug 2026 12:27:01 +0200

To: Gabriel Krisman Bertazi

Cc: notmuch@notmuchmail.org

From: Michael J Gruber


Am Do., 27. Aug. 2026 um 18:30 Uhr schrieb Gabriel Krisman Bertazi
<krisman@suse.de>:
>
>
> Hello,
>
> I'm hitting an issue with notmuch-emacs where if I search an email in a
> specific folder with tag:unread it doesn't show, but if I search without
> the tag:unread, notmuch finds it and says it has tag:unread.
>
> I removed emacs from the equation and tracked to notmuch:
>
> $ notmuch search 'thread:000000000001f39c AND folder:suse/INBOX'
> thread:000000000001f39c    August 07 [1/456(913)] Greg Kroah-Hartman| Joshua Peisach, Ronald Warsow, Pavel Machek, Shuah Khan, Thorsten Leemhuis, Brett A C Sheffield, Takeshi Ogasawara, Benjamin Boortz, Justin Forbes, Peter Schneider, Markus Reichelt, Ron Economos, Barry K. Nathan, Miguel Ojeda, Jeffrin Thalakkottoor, Mark Brown; [PATCH 7.1 293/438] io_uring/net: initialize mshot_len for send (patch signed unread)
>
> You can see it has tag:unread.  But if I add "AND tag:unread" to my search:
>
> $ notmuch search 'thread:000000000001f39c AND folder:suse/INBOX AND tag:unread'
> //no result
>
> In addition:
>
> $ notmuch search --output tags 'thread:000000000001f39c AND folder:suse/INBOX'
> patch
>
> After some debugging, I found the reason is that this message was
> cross-posted, and exists from multiple sources:
>
> $ notmuch search  --output files 'thread:000000000001f39c AND folder:suse/INBOX'
> /home/krisman/Maildir/lei/linux-fsdevel/cur/1f8e2d206fa939895a9c865a9cad26fdda96431f:2,S
> /home/krisman/Maildir/suse/INBOX/cur/1786117413.2069216_1.cartola,U=18382:2,S
> /home/krisman/Maildir/lei/INBOX/cur/1f8e2d206fa939895a9c865a9cad26fdda96431f:2,S
>
> They seem to be at least two different objects in the database:
>
> $ notmuch search  --output tags 'thread:000000000001f39c AND folder:lei/linux-fsdevel'
> patch
> signed
> unread
> $ notmuch search  --output tags 'thread:000000000001f39c AND folder:lei/INBOX'
> patch
> signed
> unread
> $ notmuch search  --output tags 'thread:000000000001f39c AND folder:suse/INBOX'
> patch
>
> So, the tags are out of sync across the cross-posts.  Is this expected?
> When I set a tag via notmuch-emacs (with +unread), should it update all
> versions of the message?
>
> In addition, The following commands seem inconsistent with each other.
> Either they both should find the INBOX copy of the message and report
> only the "patch" tag, or they should find the multiple objects and both
> report the 3 tags, IMO.
>
>
> $ notmuch search 'thread:000000000001f39c AND folder:suse/INBOX'
> thread:000000000001f39c    August 07 [1/456(913)] Greg Kroah-Hartman| Joshua Peisach, Ronald Warsow, Pavel Machek, Shuah Khan, Thorsten Leemhuis, Brett A C Sheffield, Takeshi Ogasawara, Benjamin Boortz, Justin Forbes, Peter Schneider, Markus Reichelt, Ron Economos, Barry K. Nathan, Miguel Ojeda, Jeffrin Thalakkottoor, Mark Brown; [PATCH 7.1 293/438] io_uring/net: initialize mshot_len for send (patch signed unread)
>
> $ notmuch search --output tags 'thread:000000000001f39c AND folder:suse/INBOX'
> patch
>
> In short, I could use some assistance in understanding how people deal
> with cross-posts, and whether this behavior is expected or if my
> database ended up somehow corrupted.  If that is the case, what is the
> process to regenerate it?

Before touching the database, please make sure that you are not mixing
up threads with messages. In particular, redo your searches with
`--output=messages` to check whether you get the same messages. The
database is by message.

That being said, `unread` is peculiar. Which mailstore do you use, and
do you sync flags? If you sync from mail store flags (`U`) and you
have to files with the same message ID but different `U`, it's a
matter of chance which one is read. I vaguely recall, though, that on
touching `unread` the status gets synced to all files for that mid. I
might be wrong, and an imap sync might reset it anyways.

Michael
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: