Mysql – Postfix intermittent lookup failures

MySQLpostfix

i have intermittent lookup error on my postfix/mysql/dovecot/debian when looking to virtual aliases … it happens on 10% of outgoing emails

Revelant log of a failed request :

Aug 28 12:17:43 ns212713 postfix/smtpd[17354]: connect from localhost.localdomain[127.0.0.1]
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: connection established fd 128
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: master_notify: status 0
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxymap socket: wanted attribute: request
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute name: request
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute value: lookup
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxymap socket: wanted attribute: table
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute name: table
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute value: mysql:/etc/postfix/mysql_virtual_alias_maps.cf
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxymap socket: wanted attribute: flags
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute name: flags
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute value: 16448
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxymap socket: wanted attribute: key
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute name: key
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute value: alex@trois-six.com
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxymap socket: wanted attribute: (list terminator)
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: input attribute name: (end)
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: proxy_map_find: mysql:/etc/postfix/mysql_virtual_alias_maps.cf:
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: dict_mysql_get_active: found active connection to host 127.0.0.1
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: warning: mysql query failed: Lost connection to MySQL server during query
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: send attr status = 2
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: send attr value =
Aug 28 12:17:43 ns212713 postfix/proxymap[17349]: master_notify: status 1
Aug 28 12:17:43 ns212713 postfix/smtpd[17354]: warning: proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf lookup error for "alex@trois-six.com"
Aug 28 12:17:43 ns212713 postfix/smtpd[17354]: NOQUEUE: reject: RCPT from localhost.localdomain[127.0.0.1]: 451 4.3.0 <alex@trois-six.com>: Temporary lookup failure; from=<test@conceptetdeveloppement.com> to=<alex@trois-six.com> proto=ESMTP helo=<trois-six.com>
Aug 28 12:17:43 ns212713 postfix/smtpd[17354]: lost connection after RCPT from localhost.localdomain[127.0.0.1]
Aug 28 12:17:43 ns212713 postfix/smtpd[17354]: disconnect from localhost.localdomain[127.0.0.1]
Aug 28 12:17:48 ns212713 postfix/proxymap[17349]: connection closed fd 128

Postconf :

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
dovecot_destination_recipient_limit = 1
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
message_size_limit = 52428800
mydestination = $myhostname, localhost.com, localhost
myhostname = mailserverroot.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relay_domains = proxy:mysql:/etc/postfix/mysql_relay_domains.cf
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:3000
virtual_mailbox_base = /home/facteur
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = dovecot
virtual_uid_maps = static:3000

MySQL is running fine, no big loads at the same moment, manually querying is working fine, and 90% of outgoind emails works …

I already tried some solution but no luck (127.0.0.1/localhost, mysql connections, chroot…)

Please help !

Best Answer

I have configured postfix+Dovecot+MySQL+postfixAdmin+roundcub+ClamAV+amavis.. on CentOS.

When I try to use postfixAdmin to create virtual domain and users, it is so slow, then the following error occurs

"Invalid query: MySQL server has gone away".

Steps to attempt:

  1. Change /etc/my.cnf argument into wait_timeout=28800 (it is default)
  2. Disable name resolve skip-name-resolve
  3. Try editing $CONF['emailcheck_resolve_domain'] to NO in config.inc.php and try again.