What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Jan P. Kessler-2
Dear postfix users,

today we discovered a problem with one of our mailrelays. Maillog
contains lines like the following:

Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
recipients specified

Looking deeper, we see the following:

# egrep "6B8F696F6|2737698C0" /var/log/maillog
Oct 23 10:46:58 rv-smtpext-201 postfix/smtpd[1020]: [ID 197553
mail.info] 6B8F696F6: client=mail-la0-f45.google.com[209.85.215.45]
Oct 23 10:46:58 rv-smtpext-201 postfix/cleanup[27791]: [ID 197553
mail.info] 6B8F696F6:
message-id=<[hidden email]>
Oct 23 10:46:59 rv-smtpext-201 postfix/qmgr[16441]: [ID 197553
mail.info] 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1
(queue active)
Oct 23 10:50:19 rv-smtpext-201 postfix/qmgr[10619]: [ID 197553
mail.info] 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1
(queue active)
Oct 23 10:51:21 rv-smtpext-201 postfix/qmgr[11414]: [ID 197553
mail.info] 6B8F696F6: skipped, still being delivered
Oct 23 10:51:26 rv-smtpext-201 postfix/smtp[10823]: [ID 197553
mail.info] 6B8F696F6: to=<ANONRCPT@local>,
relay=smail1.mailintern.local[10.1.1.1]:25, delay=270,
delays=203/57/10/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as
B489018F20B5)
Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 197553
mail.info] 2737698C0: uid=12345 from=<[hidden email]>
orig_id=6B8F696F6
Oct 23 10:53:00 rv-smtpext-201 postfix/cleanup[12657]: [ID 197553
mail.info] 2737698C0:
message-id=<[hidden email]>
Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
recipients specified

Can somebody explain, what is happening here? The machine also is very
slow (see delays) and might be osomewhat overloaded.

   Jan

Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Wietse Venema
Jan P. Kessler:
> Dear postfix users,
>
> today we discovered a problem with one of our mailrelays. Maillog
> contains lines like the following:
>
> Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
> mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
> recipients specified

The Postfix sendmail command awas invoked with no recipients on the
command line, and (with -t) with no recipients in the message header.

> The machine also is very slow (see delays) and might be osomewhat
> overloaded.

I suppose some software creates mailformed email messages because
it fails to detect some errors up-stream.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Jan P. Kessler-2

>> Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
>> mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
>> recipients specified
> The Postfix sendmail command awas invoked with no recipients on the
> command line, and (with -t) with no recipients in the message header.

 > I suppose some software creates mailformed email messages because it
fails to detect some errors up-stream.


To be honest. I don't understand this yet. The machine acts as a relay
which takes mails from the internet (here: gmail) and forwards them to
the next station (here: smail1.mailintern.local). There is no content
filtering, no reinjection or such - nothing that should invoke sendmail.
The configuration is quite trivial (please see below). I even do not
understand what happened after queueid 6B8F696F6 has been delivered.

# egrep "6B8F696F6|2737698C0" /var/log/maillog
Oct 23 10:46:58 rv-smtpext-201 postfix/smtpd[1020]: [ID 197553
mail.info] 6B8F696F6: client=mail-la0-f45.google.com[209.85.215.45]
Oct 23 10:46:58 rv-smtpext-201 postfix/cleanup[27791]: [ID 197553
mail.info] 6B8F696F6:
message-id=<[hidden email]>
Oct 23 10:46:59 rv-smtpext-201 postfix/qmgr[16441]: [ID 197553
mail.info] 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1
(queue active)
Oct 23 10:50:19 rv-smtpext-201 postfix/qmgr[10619]: [ID 197553
mail.info] 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1
(queue active)

- Why do we see this line twice?

Oct 23 10:51:21 rv-smtpext-201 postfix/qmgr[11414]: [ID 197553
mail.info] 6B8F696F6: skipped, still being delivered
Oct 23 10:51:26 rv-smtpext-201 postfix/smtp[10823]: [ID 197553
mail.info] 6B8F696F6: to=<ANONRCPT@local>,
relay=smail1.mailintern.local[10.1.1.1]:25, delay=270,
delays=203/57/10/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as
B489018F20B5)

- Here it got delivered. Why is the rest happening?

Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 197553
mail.info] 2737698C0: uid=12345 from=<[hidden email]>
orig_id=6B8F696F6
Oct 23 10:53:00 rv-smtpext-201 postfix/cleanup[12657]: [ID 197553
mail.info] 2737698C0:
message-id=<[hidden email]>
Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
recipients specified

- UID 12345 is the postfix user:

# grep 12345 /etc/passwd
postfix:x:12345:12345:Postfix:/var/empty:/bin/false

Postconf -n  follows. Let me know if anything else is needed:

address_verify_map = btree:$data_directory/VERIFY_ADDRESS
address_verify_negative_cache = yes
address_verify_negative_expire_time = 3d
address_verify_negative_refresh_time = 3h
address_verify_poll_count = 3
address_verify_poll_delay = 6
address_verify_positive_expire_time = 31d
address_verify_positive_refresh_time = 7d
address_verify_sender = postmaster@local
address_verify_transport_maps = btree:/etc/postfix/verify_transport
alias_database = hash:/etc/postfix/aliases
alias_maps = $alias_database
alternate_config_directories = /etc/postfix/OUT, /etc/postfix/TLSONLY
body_checks = pcre:/etc/postfix/body_checks
body_checks_size_limit = 512000
bounce_queue_lifetime = 3d
bounce_template_file = /etc/postfix/bounce.cf
command_directory = /opt/vrnetze/postfix/sbin
config_directory = /etc/postfix
daemon_directory = /opt/vrnetze/postfix/libexec
data_directory = /var/spool/postfix/DATA
debug_peer_level = 2
default_privs = nobody
delay_warning_time = 12h
disable_vrfy_command = yes
fast_flush_domains = $relay_domains
header_checks = pcre:/etc/postfix/header_checks
html_directory = no
inet_interfaces = all
luser_relay = g_vrnetze_cna_fw@local
mail_name = Mailservice
mail_owner = postfix
mailbox_size_limit = 56000001
mailq_path = /usr/bin/mailq
manpage_directory = /opt/vrnetze/postfix/man
maximal_queue_lifetime = 3d
message_size_limit = 56000000
mime_header_checks = pcre:/etc/postfix/mime_header_checks
mydestination = $myhostname, localhost.$mydomain
mydomain = local
myhostname = mail2.local
mynetworks = /etc/postfix/relay_from_networks
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases
plaintext_reject_code = 554
proxy_interfaces = 195.145.180.23, 195.145.180.24, 195.145.180.25,
195.145.180.26, 195.145.180.27, 195.145.180.28, 195.145.180.29,
195.145.180.30
queue_directory = /var/spool/postfix
readme_directory = /opt/vrnetze/postfix/doc
relay_domains = $config_directory/relay_to_domains
remote_header_rewrite_domain = domain.invalid
sample_directory = /etc/postfix
sender_canonical_maps = btree:/etc/postfix/sender_canonical
sendmail_path = /usr/lib/sendmail
setgid_group = postdrop
smtp_data_done_timeout = 660s
smtp_data_init_timeout = 240s
smtp_data_xfer_timeout = 360s
smtp_enforce_tls = no
smtp_tls_CAfile = /etc/postfix/CERTS/CAcert.pem
smtp_tls_cert_file = /etc/postfix/CERTS/cert.pem
smtp_tls_key_file = /etc/postfix/CERTS/key.pem
smtp_tls_loglevel = 1
smtp_tls_policy_maps = btree:/etc/postfix/TLS_EMPFAENGER
smtp_tls_scert_verifydepth = 8
smtp_tls_session_cache_database = btree:$data_directory/smtp_scache
smtp_tls_session_cache_timeout = 3600s
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP Mailservice
smtpd_data_restrictions = reject_unauth_pipelining,
reject_multi_recipient_bounce
smtpd_end_of_data_restrictions = check_recipient_access
btree:/etc/postfix/GROESSENBESCHRAENKUNG,       check_sender_access
pcre:/etc/postfix/NO_SMAIL_SENDER
smtpd_enforce_tls = no
smtpd_helo_required = yes
smtpd_policy_service_max_idle = 700s
smtpd_policy_service_max_ttl = 1800s
smtpd_policy_service_timeout = 600s
smtpd_proxy_timeout = 600s
smtpd_recipient_restrictions = reject_non_fqdn_recipient,
permit_mynetworks,      reject_unauth_destination, check_ccert_access
btree:/etc/postfix/tls_ccerts, check_client_access
cidr:/etc/postfix/CLIENT_WHITELIST, check_sender_access
btree:/etc/postfix/ABSENDER_WHITELIST, check_client_access
pcre:/etc/postfix/TLS_VERSENDER_CLIENTS, check_sender_access
btree:/etc/postfix/TLS_VERSENDER, check_client_access
pcre:/etc/postfix/CLIENT_BLACKLIST, check_recipient_access
pcre:/etc/postfix/EMPFAENGER_BLACKLIST, check_helo_access
pcre:/etc/postfix/HELOCHECK,  check_sender_access
btree:/etc/postfix/INTERNE_DOMAINS, check_sender_access
pcre:/etc/postfix/ABSENDER_BLACKLIST, reject_invalid_helo_hostname,  
reject_non_fqdn_sender, reject_unknown_sender_domain,  
check_sender_mx_access cidr:/etc/postfix/PRIVATE_NETZE,
reject_rbl_client zen.spamhaus.org,     check_recipient_access
btree:/etc/postfix/POLICYCHECK,  check_recipient_access
btree:/etc/postfix/VERIFY_EMPFAENGER,    permit
smtpd_restriction_classes = hapolicycheck, hagroessencheck,
hagreylistcheck, pfwpolicycheck, greylistcheck, absenderverifizierung,
empfaengerverifizierung, groessencheck
smtpd_tls_CAfile = /etc/postfix/CERTS/CAcert.pem
smtpd_tls_ask_ccert = yes
smtpd_tls_ccert_verifydepth = 8
smtpd_tls_cert_file = /etc/postfix/CERTS/cert.pem
smtpd_tls_ciphers = medium
smtpd_tls_dh1024_param_file = /etc/postfix/CERTS/dh2048.pem
smtpd_tls_dh512_param_file = /etc/postfix/CERTS/dh512.pem
smtpd_tls_eecdh_grade = strong
smtpd_tls_exclude_ciphers = EDH-RSA-DES-CBC3-SHA, DES-CBC3-SHA
smtpd_tls_key_file = /etc/postfix/CERTS/key.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = medium
smtpd_tls_mandatory_exclude_ciphers = EDH-RSA-DES-CBC3-SHA, DES-CBC3-SHA
smtpd_tls_mandatory_protocols = !SSLv2
smtpd_tls_protocols = !SSLv2
smtpd_tls_received_header = yes
smtpd_tls_req_ccert = no
smtpd_tls_session_cache_database = btree:$data_directory/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
soft_bounce = no
tls_preempt_cipherlist = yes
transport_maps = btree:/etc/postfix/fehlerdomains,
btree:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
unverified_recipient_reject_code = 550
unverified_recipient_reject_reason = User unknown -- Empfaenger nicht
gefunden

Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Viktor Dukhovni
On Fri, Oct 24, 2014 at 01:59:57PM +0200, Jan P. Kessler wrote:

> # egrep "6B8F696F6|2737698C0" /var/log/maillog
> Oct 23 10:46:58 rv-smtpext-201 postfix/smtpd[1020]: [ID 197553 mail.info]
> 6B8F696F6: client=mail-la0-f45.google.com[209.85.215.45]
> Oct 23 10:46:58 rv-smtpext-201 postfix/cleanup[27791]: [ID 197553 mail.info]
> 6B8F696F6:
> message-id=<[hidden email]>

> Oct 23 10:46:59 rv-smtpext-201 postfix/qmgr[16441]: [ID 197553 mail.info]
> 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1 (queue active)

Notice that the queue-manager process id changes below!  Something
is running frequent "postfix reload" operations.

> Oct 23 10:50:19 rv-smtpext-201 postfix/qmgr[10619]: [ID 197553 mail.info]
> 6B8F696F6: from=<[hidden email]>, size=129401, nrcpt=1 (queue active)
>
> - Why do we see this line twice?
>
> Oct 23 10:51:21 rv-smtpext-201 postfix/qmgr[11414]: [ID 197553 mail.info]
> 6B8F696F6: skipped, still being delivered

And the queue-manager pid changes yet again!  DO NOT DO THAT!

> Oct 23 10:51:26 rv-smtpext-201 postfix/smtp[10823]: [ID 197553 mail.info]
> 6B8F696F6: to=<ANONRCPT@local>, relay=smail1.mailintern.local[10.1.1.1]:25,
> delay=270, delays=203/57/10/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok:
> queued as B489018F20B5)

Finally the message is delivered, but in the mean-time:

> Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 197553 mail.info]
> 2737698C0: uid=12345 from=<[hidden email]> orig_id=6B8F696F6
> Oct 23 10:53:00 rv-smtpext-201 postfix/cleanup[12657]: [ID 197553 mail.info]
> 2737698C0:

Someone has moved the queue file to the maildrop directory while that was
happening via "postsuper -r ALL".

> message-id=<[hidden email]>
> Oct 23 10:53:00 rv-smtpext-201 postfix/pickup[11413]: [ID 947731
> mail.warning] warning: maildrop/6B8F696F6: error writing 2737698C0: no
> recipients specified

TOO MUCH MANUAL QUEUE MANAGEMENT.

> smtpd_tls_exclude_ciphers = EDH-RSA-DES-CBC3-SHA, DES-CBC3-SHA

If you don't want 3DES, better would be:

    smtpd_tls_exclude_ciphers = 3DES

There are more 3DES ciphers these days.

> smtpd_tls_mandatory_exclude_ciphers = EDH-RSA-DES-CBC3-SHA, DES-CBC3-SHA

This is redundant, the ciphers excluded with opportunistic TLS are
also excluded with mandatory TLS.

> smtpd_use_tls = yes

Better:

        smtpd_tls_security_level = may

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Wietse Venema
In reply to this post by Jan P. Kessler-2
A maildrop queue file is created when something submits mail with
the Postfix sendmail command, or when a maildrop queue file is
renamed from the incoming/active/deferred queue with the "postsuper
-r" command.

Local submission:
    sendmail command command->postdrop command->maildrop queue file->
        pickup daemon->cleanup daemon->incoming queue file

"postsuper -r" resubmission:
    existing incoming or deferred queue file->maildrop queue file

It would be helpful if the pickup daemon logged the owner UID of
the maildrop queue file. That would help to distinguish between
local submission or "postsuper -r" resubmission.

But it doesn't. So we use a different way to make the distinction:
each method produces different error messages for "no recipients".

Invoking "postsuper -r" for a queue file after all its recipients
are delivered will result in the above error message.

We can eliminate the postfix sendmail command from consideration,
because that results in a different error when a submission has no
recipients:

$ sendmail </dev/null
sendmail: fatal: Recipient addresses must be specified on the command line or via the -t option

$ sendmail -t < /dev/null
sendmail: fatal: wietse(1001): No recipient addresses found in message header

So I speculate that what you see was the result of a "postsuper -r"
race condition.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Viktor Dukhovni
On Fri, Oct 24, 2014 at 09:24:13AM -0400, Wietse Venema wrote:

> A maildrop queue file is created when something submits mail with
> the Postfix sendmail command, or when a maildrop queue file is
> renamed from the incoming/active/deferred queue with the "postsuper
> -r" command.
>
> Local submission:
>     sendmail command command->postdrop command->maildrop queue file->
> pickup daemon->cleanup daemon->incoming queue file
>
> "postsuper -r" resubmission:
>     existing incoming or deferred queue file->maildrop queue file
>
> It would be helpful if the pickup daemon logged the owner UID of
> the maildrop queue file. That would help to distinguish between
> local submission or "postsuper -r" resubmission.
>
> But it doesn't.

Actually it does and it did, that's why the "original id" was
logged.  This was a "postsuper -r".

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Wietse Venema
Viktor Dukhovni:

> On Fri, Oct 24, 2014 at 09:24:13AM -0400, Wietse Venema wrote:
> > A maildrop queue file is created when something submits mail with
> > the Postfix sendmail command, or when a maildrop queue file is
> > renamed from the incoming/active/deferred queue with the "postsuper
> > -r" command.
> >
> > Local submission:
> >     sendmail command command->postdrop command->maildrop queue file->
> > pickup daemon->cleanup daemon->incoming queue file
> >
> > "postsuper -r" resubmission:
> >     existing incoming or deferred queue file->maildrop queue file
> >
> > It would be helpful if the pickup daemon logged the owner UID of
> > the maildrop queue file. That would help to distinguish between
> > local submission or "postsuper -r" resubmission.
> >
> > But it doesn't.
>
> Actually it does and it did, that's why the "original id" was
> logged.  This was a "postsuper -r".

In any case we both deduced this was a "postsuper -r" race condition.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Jan P. Kessler-2
In reply to this post by Wietse Venema

Viktor:
> TOO MUCH MANUAL QUEUE MANAGEMENT.

Wietse:
> So I speculate that what you see was the result of a "postsuper -r"
> race condition.

Thanks! That was it. A colleague told me, that the queue on that system
and a subsequent content filter had been congested and users were
waiting impatiently for their mail. Therefore he changed routing to skip
the subsequent content filter and ran "postsuper -r ALL" and "postfix
flush" several times within short timeframe - maybe even in parallel
(more than 1 colleague). Some of them also used "postqueue -i ALL".

I'll advise them to let postfix queue management do it's job and to be
careful with such actions.

And also thanks for the TLS related configuration hints. I'll update the
configuration accordingly.

Just one more question: Looking at the queue directories, I found:

# find /var/spool/postfix/defer -type f|wc -l
     13532

While postqueue sais:

# postqueue -p
Mail queue is empty

Is this also a consequence of too much manual queue management, maybe in
combination with a race condition? Is it safe to stop postfix and delete
these files (maybe with find -mtime +30 or such)? Nobody has reported
missing e-mails and the files are rather old:

-rw-------   1 postfix  postfix      372 Oct 31  2011 F3A1DE7C0
-rw-------   1 postfix  postfix      529 Oct 25  2011 F3A409CC5
-rw-------   1 postfix  postfix      362 Oct  9  2013 F3AF29F61
-rw-------   1 postfix  postfix      362 Oct  9  2013 F3B01ACC8
-rw-------   1 postfix  postfix      524 Feb 24  2012 F3B84116E4
-rw-------   1 postfix  postfix      337 Jul 22  2013 F3BC458AD
...

Thank you very much!

    Jan

Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Wietse Venema
Jan P. Kessler:
> Viktor:
> > TOO MUCH MANUAL QUEUE MANAGEMENT.
>
> Just one more question: Looking at the queue directories, I found:
>
> # find /var/spool/postfix/defer -type f|wc -l
>      13532

Bleh.

> While postqueue sais:
>
> # postqueue -p
> Mail queue is empty
>
> Is this also a consequence of too much manual queue management,

No mail is lost if these files are orphans after "postsuper -r/-h"
manipulations. All other manipulations will result in loss of email
(email that was not delivered, without sender notification).

> Is it safe to stop postfix and delete these files (maybe with find
> -mtime +30 or such)? Nobody has reported missing e-mails and the
> files are rather old:

These files will eventually be reused, but removing old files
"should" be safe.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

Viktor Dukhovni
In reply to this post by Jan P. Kessler-2
On Fri, Oct 24, 2014 at 03:55:55PM +0200, Jan P. Kessler wrote:

>
> # find /var/spool/postfix/defer -type f|wc -l
>     13532

These are not mail messages (those would be in "deferred" not
"defer").  These are "defer logs", used to construct the per-recipient
error reasons in bounce messages.

They are best left alone, but can be deleted with care, something
along the lines of:

        # postfix stop
        # postsuper -s
        # cd /var/spool/postfix
        # (find defer -type f -print;
           find deferred -type f -print) |
          perl -lne '
                if (m{^defer/(?:.*/)?(.*)$}) {
                    $defer{$1} = $_;
                } elsif (m{^deferred/(?:.*/)?(.*)$}) {
                    delete $defer{$1};
                }
                END {
                    while (($id, $path) = each(%defer)) {
                        if (unlink($path)) {
                            printf "%s defer log deleted\n", $id;
                        } else {
                            warn "unlink: $path: $!\n";
                        }
                    }
                }
            '

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: What exactly does that mean: maildrop/6B8F696F6: error writing 2737698C0: no recipients specified

A. Schulze
Viktor Dukhovni:

> They are best left alone, but can be deleted with care, something
> along the lines of:
>
> # postfix stop
> # postsuper -s
> # cd /var/spool/postfix
> # (find defer -type f -print;
>   find deferred -type f -print) |
>  perl -lne '
> if (m{^defer/(?:.*/)?(.*)$}) {
>    $defer{$1} = $_;
> } elsif (m{^deferred/(?:.*/)?(.*)$}) {
>    delete $defer{$1};
> }
> END {
>    while (($id, $path) = each(%defer)) {
> if (unlink($path)) {
>    printf "%s defer log deleted\n", $id;
> } else {
>    warn "unlink: $path: $!\n";
> }
>    }
> }
>    '

I had a similiar issue some years ago. A heavy loaded defer queue was so slow.
I noticed these orphaned files in defer/. I had the feeling the qmgr acts faster after removing them.
For that reason I implemented a cronjob to search (but not delete) orphaned files once a day.

cd ${QUEUE_DIR}/defer/
for deferinfo in `find . -type f`; do
  if [ ! -f "../deferred/${deferinfo}" ]; then
    ORPHANED_FILES="${ORPHANED_FILES} ${QUEUE_DIR}/defer/${deferinfo}"
fi
done
if test ! -z "${ORPHANED_FILES}"; then
  echo
  echo '* Infodateien ohne Queuedateien:'
  echo '--------------------------------'
  echo ${ORPHANED_FILES} | xargs ls -la
fi

That cronjob produces output very rarely but mostly after manual interaction
( postsuper -r ALL and so )

Andreas