[POP3][Maildir] - Dovecot index gets corrupted, when using maildir as mailbox format and Thunderbird as mail client

If you spin up the test environment with dovecot_mailbox_type: maildir as mailbox format and use it with Thunderbird and POP3, the dovecot index gets corrupted from time to time. Thats happening in dovecot 2.2.34 as well as in .37:

Content of /var/log/syslog:

Aug 10 16:02:45 trees dovecot: pop3(treesenabled@trees.testing): Debug: trees plugin initialized
Aug 10 16:02:45 trees dovecot: pop3(treesenabled@trees.testing): Error: Maildir filename has wrong S value, renamed the file from /var/vmail/trees.testing/treesenabled/Maildir/cur/1533916956.M735664P6086.trees,S=1456,W=748:2, to /var/vmail/trees.testing/treesenabled/Maildir/cur/1533916956.M735664P6086.trees,S=783:2,
Aug 10 16:02:45 trees dovecot: pop3(treesenabled@trees.testing): Error: Corrupted record in index cache file /var/vmail/trees.testing/treesenabled/Maildir/dovecot.index.cache: UID 1: Broken physical size in mailbox INBOX: read(/var/vmail/trees.testing/treesenabled/Maildir/cur/1533916956.M735664P6086.trees,S=1456,W=748:2,) failed: Cached message size larger than expected (1456 > 728, box=INBOX, UID=1)
Aug 10 16:02:45 trees dovecot: pop3(treesenabled@trees.testing): Disconnected: Logged out top=0/0, retr=1/764, del=0/1, size=748

Steps to reproduce

  • spin up vagrant testbox (from PR!11) (dovecot-2.2.34)
  • connect via Thunderbird and POP3
  • send mail , watch it crashing

Observings

Since IMAP und POP3 use the same code. That behavior is pretty strange.

APPENDIX

# 2.2.34 (874deae): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.22 (22940fb7)
# OS: Linux 4.9.0-6-amd64 x86_64 Debian 9.4 
# Hostname: trees.testing
auth_mechanisms = plain login
instance_name = trees.testing
login_greeting = trees.testing ready.
mail_gid = 5000
mail_home = /var/vmail/%Ld/%Ln
mail_location = maildir:~/Maildir
mail_plugins = " quota trees"
mail_uid = 5000
mailbox_list_index = yes
namespace inbox {
  inbox = yes
  location = 
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
    auto = subscribe
    autoexpunge = 30 days
    special_use = \Junk
  }
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    auto = subscribe
    autoexpunge = 30 days
    special_use = \Trash
  }
  prefix = 
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocols = " imap pop3"
service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
  }
  unix_listener auth-userdb {
    group = vmail
    mode = 0660
  }
}
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  process_min_avail = 4
}
service imap {
  executable = imap
}
service pop3 {
  executable = pop3
}
ssl = required
ssl_cert = </etc/ssl/certs/ssl-cert-snakeoil.pem
ssl_cipher_list = ALL:!LOW:!RC4:!EXP:!aNULL
ssl_dh_parameters_length = 2048
ssl_key =  # hidden, use -P to show it
ssl_prefer_server_ciphers = yes
userdb {
  driver = prefetch
}
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}