After systemd integration enabled, Postfix will no longer send mail on startup

Bug #1627117 reported by Michael Marley
44
This bug affects 7 people
Affects Status Importance Assigned to Milestone
postfix (Ubuntu)
Fix Released
Medium
Unassigned
Nominated for Yakkety by Joshua Powers

Bug Description

This occurs because /etc/resolv.conf gets copied to /var/spool/postfix/resolv.conf before the network is up and therefore before it contains any useful data. Therefore, every message fails to be sent or received with a message such as "dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=example.com type=MX: Host not found, try again)". If Postfix is restarted or if the file is manually copied into the chroot again, Postfix resumes normal operation.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi,
thank you for reporting this issue and the pre-analysis.

I wonder why the After=network.target in the service isn't protecting this enough.

Since you already checked so much, could you outline which script is doing the copy of resolv.conf on postfix initialization?
That should be the one that would be supposed to run "later" once all of the network is ready.

Also finally since you are referring to systemd - are you testing Xenial or Yakkety?

I prepped already a bit of a trivial repro case:

lxc launch images:ubuntu/yakkety/amd64 test-pf
lxc exec test-pf apt-get update
# choose the simple local only config
lxc exec test-pf apt-get install postfix
lxc exec test-pf reboot
lxc exec test-pf ls -laF /var/spool/postfix/etc/
lxc exec test-pf cat /var/spool/postfix/etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
lxc exec test-pf cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.4.1
search lxd

With that I see the "old" content of resolv.conf prior to it being updated.
Is that enough in your opinion as recreation of the case?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in postfix (Ubuntu):
status: New → Confirmed
Changed in postfix (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Medium
Revision history for this message
Michael Marley (mamarley) wrote :

Yes, what you did with lxc seems to be reproducing the same issue I am seeing.

I am running Yakkety, but I actually did try backporting the package to Xenial and saw the same issue there too.

The script that copies the /etc/resolv.conf (and other files) into the chroot is /usr/lib/postfix/configure-instance.sh, which is called as an ExecStartPre in /lib/systemd/system/postfix@.service.

Changed in postfix (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Jhair Tocancipa Triana (jhair-tocancipa-j) wrote :

I'm facing this bug after upgrading from xenial to yakkety.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety

Revision history for this message
Scott Kitterman (kitterman) wrote :

This is fixed in Debian and Ubuntu Zakkety. Someone involved in Ubuntu development will need to do an SRU to fix the earlier releases. You need these two commits:

https://git.launchpad.net/postfix/commit/?h=stable/v3.1&id=6a19708c5e0dfd188df8898028a9977b811230f5
https://git.launchpad.net/postfix/commit/?h=stable/v3.1&id=afb4b8a81c9eb00c4782560b578bb618f2e93662

tags: added: patch server-next
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package postfix - 3.1.3-2

---------------
postfix (3.1.3-2) unstable; urgency=medium

  [Scott Kitterman]

  * Use main/master.cf from /usr/share/postfix/ for multi-instance prototypes
    rather than from /etc/postfix as, depending on configuration, they may not
    always exist in the latter location. Closes: #842133

  [localization folks]

  * l10n: Updated Dutch translations. Closes: #834614 (Frans Spiesschaert)

 -- Scott Kitterman <email address hidden> Sun, 30 Oct 2016 07:56:02 -0400

Changed in postfix (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Ross Patterson (rossp) wrote :

I manually applied the 2 commits in https://bugs.launchpad.net/ubuntu/+source/postfix/+bug/1627117/comments/5 but the problem still occurs, so I doubt the new release is a fix.

Revision history for this message
Ross Patterson (rossp) wrote :

To clarify my testbed, I can reliably reproduce this issue by rebooting a laptop with Ubuntu Desktop 16.10 installed. Neither restarting the network-manager service, nor reconnecting to the same network using the nm-applet reproduce the issue, but rebooting does.

Revision history for this message
Shawn Stephens (shawn-stephens) wrote :

I'm seeing the same issue on 17.04 with postfix. The patch described here is implemented in postfix-3.1.4-4, but I still have to update the resolve.conf in the postfix chroot every time I reboot.

Revision history for this message
advseb (adv-seb) wrote :

I can also reproduce this problem on a clean Kubuntu 17.04 installation I did yesterday.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty

$ sudo apt list postfix:
Auflistung... Fertig
postfix/zesty,now 3.1.4-4 amd64 [Installiert,automatisch]

Please re-open this bug!

Revision history for this message
heynnema (heynnema) wrote :

I fixed this problem. In my case it had to do with booting from a SSD, and not all services had completed their startup when postfix was started. Please see:

https://askubuntu.com/questions/929407/postfix-problem-when-started-from-ssd/931070?noredirect=1#comment1505997_931070

It looks like I was on the right path to solving my Postfix problem.

I ended up changing this:

~$ cd /etc/systemd/system/postfix.service.d

~$ more override.conf
[Unit]
After=network-online.target
After=systemd-resolved.service

To this:

~$ cd /etc/systemd/system/postfix.service.d

~$ more override.conf
[Unit]
#After=network-online.target
#After=systemd-resolved.service

Revision history for this message
Russell Morris (6-u3untu-h) wrote :

Hi,

Just recently upgraded (16.04 LTS => 17.04), and I can confirm this bug and workaround / fix as well. It definitely exists in 17.04.

Is the fix "OK"? Meaning what does it potentially break?

Thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.