Hello,

I am using dovecot-lda as delivery for virtual users, Since upgrading
from debian 10 (postfix 3.4.23, dovecot 2.3.16) to debian 11 (postfix
3.5.25, dovecot 2.3.21), it seems postfix is using parallel delivery
of multiple emails to the same recipient, which breaks sieve
"duplicate" filter (it saves info about a message only after it is
delivered, so when another delivery starts in between, it is not
considered duplicate). So I would call this a race condition in the
implementation of the sieve filter, however it did not trigger before
the upgrade. I have double-checked both postfix and dovecot configs
and they did not change during the upgrade.

Do I understand correctly that "dovecot_destination_recipient_limit=1"
should start delivery of 2nd email to the same recipient address only
after the 1st one is finished?

### master.cf:
# https://doc.dovecot.org/2.3/configuration_manual/howto/dovecot_lda_postfix/
# flag O: Prepend an "X-Original-To: recipient" message header with
the recipient address as given to Postfix.
# Sieve filtering would work also without it (based on "-a"
parameter), but no header would be added to the message, so users
would need to guess it from the Received headers
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhuO user=vmail:vmail argv=/usr/lib/dovecot/dovecot-lda -f
${sender} -a ${original_recipient} -d ${user}@${nexthop}

### postconf -n|grep dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_type = dovecot
virtual_transport = dovecot

### Example delivery (they are using sender-based bcc + aliases):
# postfix log:
Jun 24 11:02:24 baru postfix/qmgr[6132]: 8F811C3: from=<st...@xx.tld>,
size=323532, nrcpt=7 (queue active)
Jun 24 11:02:25 baru postfix/pipe[2912693]: 8F811C3:
to=<st...@xx.tld>, relay=dovecot, delay=2.6, delays=1.8/0.14/0/0.72,
dsn=2.0.0, status=sent (delivered via dovecot service)
Jun 24 11:02:25 baru postfix/pipe[2913055]: 8F811C3:
to=<ruff...@xx.tld>, orig_to=<st...@xx.tld>, relay=dovecot, delay=3.2,
delays=1.8/0.13/0/1.3, dsn=2.0.0, status=sent (delivered via dovecot
service)
Jun 24 11:02:26 baru postfix/pipe[2913052]: 8F811C3:
to=<ruff...@xx.tld>, orig_to=<stani-bcc@bcc.localhost>, relay=dovecot,
delay=3.5, delays=1.8/0.11/0/1.6, dsn=2.0.0, status=sent (delivered
via dovecot service)
Jun 24 11:02:26 baru postfix/pipe[2912688]: 8F811C3: to=<m...@xx.tld>,
orig_to=<st...@xx.tld>, relay=dovecot, delay=3.8,
delays=1.8/0.13/0/1.9, dsn=2.0.0, status=sent (delivered via dovecot
service)
Jun 24 11:02:26 baru postfix/pipe[2913235]: 8F811C3:
to=<st...@xx.tld>, orig_to=<stani-bcc@bcc.localhost>, relay=dovecot,
delay=4.3, delays=1.8/0.12/0/2.4, dsn=2.0.0, status=sent (delivered
via dovecot service)
Jun 24 11:02:27 baru postfix/pipe[2912705]: 8F811C3: to=<m...@xx.tld>,
orig_to=<stani-bcc@bcc.localhost>, relay=dovecot, delay=4.6,
delays=1.8/0.11/0/2.7, dsn=2.0.0, status=sent (delivered via dovecot
service)

# lda log:
Jun 24 11:02:25 baru dovecot:
lda(st...@xx.tld)<2913897><qgE4JqBpWmhpdiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'
Jun 24 11:02:25 baru dovecot:
lda(ruff...@xx.tld)<2913896><O86dJqBpWmhodiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'
Jun 24 11:02:25 baru dovecot:
lda(ruff...@xx.tld)<2913893></rgrLqBpWmhldiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'
Jun 24 11:02:26 baru dovecot:
lda(m...@xx.tld)<2913895><rGWfJqBpWmhndiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'
Jun 24 11:02:26 baru dovecot:
lda(st...@xx.tld)<2913894><xl5SKqBpWmhmdiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'
Jun 24 11:02:27 baru dovecot:
lda(m...@xx.tld)<2913892><Ph8JKKBpWmhkdiwAk9ePBw>: sieve:
msgid=<ew7pne1ffdwsutafug7zdlsaogrb5bibqb9latp...@app.tld>: stored
mail into mailbox 'INBOX'

### strace log for ruffini@
# lda PID 2913896
11:02:24.445662 Process start
11:02:25.680883 rename("/home/vmail/.dovecot.lda-dupes.lock",
"/home/vmail/.dovecot.lda-dupes") = 0
11:02:25.694057 +++ exited with 0 +++

# lda PID 2913893
11:02:24.425980 Process start
11:02:25.988260 rename("/home/vmail/.dovecot.lda-dupes.lock",
"/home/vmail/.dovecot.lda-dupes") = 0
11:02:25.999585 +++ exited with 0 +++

So clearly there were running 2 dovecot-lda processes delivering
emails to the same recipient (ruffini@), so the sieve filter had no
chance of identifying it as a duplicate.

Shouldn't "dovecot_destination_recipient_limit=1" prevent such a thing?
I can probably limit the process count for "dovecot" transport in
master.cf (or limit it in dovecot conf), but that would prevent
parallel delivery even to different mailboxes.


-- 
  bye, Marki
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to