Hello,

   We run Dovecot 2.4.5 (Alpine package 2.4.5-r0, x86_64, in Docker, maildir
   on ext4, no NFS) and found a crash we can reproduce reliably.

   Symptom: several imap processes that are appending to the same mailbox
   crash within a few seconds of each other:

   imap([email protected])<pid>: Error: Mailbox INBOX: Log synchronization
   error at seq=2,offset=340580 for .../dovecot.index: ext hdr update:
   invalid record size

   imap([email protected])<pid>: Warning: ... fscking index file

   master: Fatal: service(imap): child <pid> killed with signal 11 (core
   dumped)

   Sometimes we see "Extension header update points outside header size"
   instead of the first line.

   Where: the kernel's segfault line ("error 4 in
   libdovecot-storage.so.0.0.0") resolves, every time, to the same
   instruction inside mail_index_sync_record(), in the
   MAIL_TRANSACTION_EXT_HDR_UPDATE loop of
   src/lib-index/mail-index-sync-update.c. After
   mail_index_sync_ext_hdr_update(ctx, rec->offset, rec->size, rec + 1)
   returns, the next read of rec->size (to step to the next record) faults.
   It looks as though the transaction log data that rec points into has been
   unmapped or replaced inside that call. Our guess: for the modseq
   extension, mail_index_sync_ext_hdr_update() calls
   mail_index_modseq_hdr_update(), whose mail_index_modseq_sync_init() opens
   a second log view and reads the log from the modseq header's old position,
   which can remap the same log file the outer loop is still walking.

   We checked main as of today (84b4143). The two modseq fixes from October
   (14a2352, 03a7fd6) handle an index that already has a broken modseq
   header. The EXT_HDR_UPDATE loop and mail_index_modseq_sync_init() look
   unchanged, so we believe this is still open.

   How to reproduce:

    1. A fresh maildir mailbox that no CONDSTORE session has opened yet, so
       its dovecot.index has no modseq extension.

    2. Eight parallel sessions APPENDing (UIDPLUS) to INBOX and Sent in a
       loop for 60 seconds.

    3. About 35 seconds into the burst, one more session that has sent ENABLE
       CONDSTORE opens the mailbox (EXAMINE, then UID FETCH 1:* (UID FLAGS
       ENVELOPE INTERNALDATE)). A LIST ... RETURN (STATUS (MESSAGES UIDNEXT
       HIGHESTMODSEQ)) at the same moment triggers it too.

   Result: one or more of the appending sessions crash in most runs (in one
   series, 3 of 6 bursts, 1 to 11 sessions each). The last ext-intro before
   the error offset in dovecot.index.log is "modseq" (hdr_size 16,
   record_size 8).

   What does not trigger it:

     o The same late session without ENABLE CONDSTORE (and without
       HIGHESTMODSEQ in STATUS): 0 crashes in more than 20 runs.

     o A CONDSTORE session that opens the mailbox early in the burst, while
       the log is still small: 0 crashes in 3 runs.

   So it seems to need the modseq extension to be introduced while other
   processes are appending and the transaction log is already large.

   Data: nothing was lost on disk. Every APPEND the server acknowledged is
   present with its APPENDUID, and doveadm force-resync changes nothing
   afterwards. The APPEND that was in flight in a crashed session was
   committed, although its client got EOF.

   Relevant settings (doveconf -n excerpt): mail_driver = maildir;
   mail_plugins = lazy_expunge quota (and sieve for lmtp);
   lazy_expunge_only_last_instance = no; protocols = imap pop3 lmtp sieve;
   imap4rev2_enable = no; mmap_disable and mail_fsync at their defaults.

   We could not capture a core file in our container setup. We can try for a
   full backtrace with debug symbols if that would help.

   As a workaround, our own clients no longer enable CONDSTORE, so they never
   introduce the modseq extension. Mail clients that use CONDSTORE can
   presumably still hit this.

   Thank you,

   JustEmails

   https://justemails.app
_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to