Subject: Gnus hangs on: "Cannot find file in ~/Maildir/IMAPBOX/Sent/cur"

From: Bastien Guerry <[email-masked]>
Date: Sat, 03 Feb 2018 19:14:33 +0100

Hi,

I use Gnus v0.14 with Emacs 27.0.50, built from master on 2018-02-01.

I’m syncing three IMAP inboxes using mbsync then read them in Gnus:

(setq mail-sources nil
      gnus-select-method '(nnmaildir "Bastien" (directory "~/Maildir"))
      gnus-secondary-select-methods
      '((nnmaildir "imapbox1" (directory "~/Maildir/imapbox1"))
        (nnmaildir "imapbox2" (directory "~/Maildir/imapbox2"))
	(nnmaildir "imapbox3" (directory "~/Maildir/imapbox3"))))

After I run mbsync (manually, when I want to check for new emails),
I run ‘notmuch new’ to index emails.

I manually launch mbsync when I need to fetch new emails.

It worked perfectly until a few months ago.  AFAIK my setup didn’t
change, just the Gnus / Emacs version.

The error I get:

1. I try to send an email.

2. Emacs hangs.

3. It seems a single C-g cannot stop the process.

4. I have to press C-g without releasing the key to get an error
   buffer.  Then I kill the buffer to kill the process that is
   attached to it.

5. The error says that Gnus cannot find a file in a
   "~/Maildir/imapbox1/Sent/cur/" folder.

   When I check, the email is correctly sent, but the mark in the
   local IMAP inboxes looks wrong (I’m not sure). I have this file:

   1517659181.M377519P14211Q0.bzg:2,

   while I would expect something like

   1517659181.M377519P14211Q0.bzg,U=7290:2,S

6. Also, I have this archiving function:

   (defun my-gnus-message-archive-group (group-current)
      "Return prefered archive group."
      (let ((group-prefix (replace-regexp-in-string "[^:]+$" "" group-current)))
        (cond
         ((string-match "data" group-prefix)
    	  (concat group-prefix "Sent"))
         ((message-news-p)
          (concat "nnfolder+archive:" (format-time-string "%Y-%m")
                  "-divers-news"))
         (t "nnmaildir+bzgfr:Sent"))))

7. I have ~7000 files in "~/Maildir/imapbox1/Sent/cur/" and writing
   a new file here might be rather slow (I haven’t properly tested).
   Could the bug be that Gnus is trying to access a file that isn’t
   written yet?
    
8. I guess there is some race condition while writing the sent file or
   something, but I cannot find the conditions on how to reproduce the
   bug.  It happens at least once every hour, rendering Emacs and Gnus
   pretty unusable.

Is anyone having similar problems?

Are there parameters that I can test to track this bug?

Thanks in advance for any help!

Ma Gnus v0.14
GNU Emacs 27.0.50 (build 35, i686-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2018-02-01

-- 
 Bastien