djcb / mu

maildir indexer/searcher + emacs mail client + guile bindings
http://www.djcbsoftware.nl/code/mu
GNU General Public License v3.0
1.62k stars 391 forks source link

[mu/mu4e bug] updates made via mu4e not visible to external mu queries anymore #2737

Closed mbunkus closed 3 months ago

mbunkus commented 3 months ago

Describe the bug

I have tmux set up to show the number of unread mails in the status line. For that tmux runs a search that boils down to mu find flag:unread.

Until updating yesterday from 1.12.5 to 1.12.6 (complete with reboot afterwards) this worked just fine. As soon as new mail arrived, I could find it both in mu4e & mu, and therefore tmux updated the number of unread mail.

This doesn't work reliably anymore. Directly after starting mu4e the external mu find still finds those mails. However, that stops at some point. Currently I can find exactly one email when searching with mu4e for flag:unread, but mu find flag:unread finds no mail whatsoever.

I can make it work for some time again by quitting mu4e. As soon as I do that, mu find finds the unread email. I can even restart mu4e; mu find still finds it. After an undetermined amount of time it cannot find anything anymore.

To Reproduce

Run mu4e 1.12.6, let it find new mail. Don't read it in mu4e, but search for flag:unread & note the number if mails shown in mu4e. Compare that to the amount found with mu find flag:unread run from a separate shell. If it matches, wait a while & compare.

I haven't found a way to reliably trigger the behavior.

Environment

Arch Linux. Emacs, mu are Arch packages. Emacs 29.4 (Arch package emacs-nativecomp 29.4-1), mu 1.12.6 (Arch package 1.12.6-2).

I'm 100% certain this used to work with 1.12.5-1 which, according to /var/log/pacman.log, I had been running since 2024-05-25 until yesterday, at which point the weird behavior started.

Currently there are no updates available for Emacs nor mu.

I have not tried downgrading yet.

Checklist

djcb commented 3 months ago

Thanks for the report.

Generally, there's no expectation that mu4e-changes are immediately visible when viewed externally; for accurate number it's probably best to use something directly talking to mu4e (which isn't too hard when using emacsclient).

That being said, it is a change of behavior (as part of changes for an unrelated issue) so I've make it do a disk-sync now after indexing completes.

mbunkus commented 3 months ago

Thank you so much for the incredibly quick fix. I've been running f01360ae9fefc488fe3e439884fc1499c7bdcdcb since yesterday, it it looks to be fixed for me.

djcb commented 3 months ago

Ah, great to hear, thanks!

jtoloe commented 3 months ago

@djcb Sorry to hijack but could you elaborate on the proper way to use mu4e through emacsclient for something like this? I ran into this issue as well because I couldn't figure out how to get a list of related msgid's from a msgid query using mu4e. I resorted to running mu find -r -f i "msgid:<msgid>" which has worked quite well for several years.