Bug 17219 - dovecot doesn't start at boot time because network is not up yet
Summary: dovecot doesn't start at boot time because network is not up yet
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 5
Hardware: i586 Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard: MGA5-32-OK MGA5-64-OK advisory
Keywords: validated_update
Depends on:
Blocks:
 
Reported: 2015-11-25 12:27 CET by Nicolas Pomarède
Modified: 2015-12-05 00:32 CET (History)
5 users (show)

See Also:
Source RPM: dovecot-2.2.13-5.1.mga5
CVE:
Status comment:


Attachments

Description Nicolas Pomarède 2015-11-25 12:27:33 CET
Description of problem:

Hello

this problem is in fact similar to bug #16642 for dhcpd.

On boot, for some reasons on my PC, it seems the network interface doesn't come up fast enough before dovecot.service is started.

This gives the following errors at boot :

dovecot[1369]: Error: bind(192.168.108.147, 110) failed: Cannot assign requested address
dovecot[1369]: Error: service(pop3-login): listen(192.168.108.147, 110) failed: Cannot assign requested address
dovecot[1369]: Error: bind(192.168.108.147, 995) failed: Cannot assign requested address
dovecot[1369]: Error: service(pop3-login): listen(192.168.108.147, 995) failed: Cannot assign requested address
dovecot[1369]: Error: bind(192.168.108.147, 143) failed: Cannot assign requested address
dovecot[1369]: Error: service(imap-login): listen(192.168.108.147, 143) failed: Cannot assign requested address
dovecot[1369]: Error: bind(192.168.108.147, 993) failed: Cannot assign requested address
dovecot[1369]: Error: service(imap-login): listen(192.168.108.147, 993) failed: Cannot assign requested address
dovecot[1369]: Fatal: Failed to start listeners

In my case, the solution was to modify /usr/lib/systemd/system/dovecot.service and to change :

After=local-fs.target network.target
to
After=local-fs.target network-online.target

After this, dovecot starts successfully on each boot.

Maybe others services opening a listen socket at boot should be changed to use network-online.target (apache, spamd, ...) as I think the problem would happen there too depending on how fast the PC boots compared to the time it really takes for the network interfaces to come up and depending on which order those services will be started (in my case, dovecots fails, but spamd starts ok just after)



Reproducible: 

Steps to Reproduce:
Comment 1 David Walser 2015-11-25 14:09:34 CET
Thanks for the report.  You're correct on this.  Upstream really dropped the ball by changing this (which they shouldn't have) and not communicating it effectively.  Even Fedora has yet to fully adapt to this change.  You can see in your logs that bind has the same problem, but at least it's able to wait on its own and adapt to the problem.  However, I have fixed bind in SVN and the fix will be included in the next (inevitable) security update for it.

I have looked at some other services that theoretically seem like they should need to be changed for this too, but in practice haven't found any others that aren't working.

Patched packages uploaded for Mageia 5 and Cauldron.

Advisory:
-----------------------------------------

The dovecot service was not correctly waiting for the network to be up before
attempting to start, causing it to fail to start at boot time in some cases.

-----------------------------------------

Updated packages in core/updates_testing:
-----------------------------------------
dovecot-2.2.13-5.2.mga5
dovecot-pigeonhole-2.2.13-5.2.mga5
dovecot-pigeonhole-devel-2.2.13-5.2.mga5
dovecot-plugins-pgsql-2.2.13-5.2.mga5
dovecot-plugins-mysql-2.2.13-5.2.mga5
dovecot-plugins-ldap-2.2.13-5.2.mga5
dovecot-plugins-gssapi-2.2.13-5.2.mga5
dovecot-plugins-sqlite-2.2.13-5.2.mga5
dovecot-devel-2.2.13-5.2.mga5

from dovecot-2.2.13-5.2.mga5.src.rpm

CC: (none) => luigiwalser
Assignee: bugsquad => qa-bugs

Comment 2 Nicolas Pomarède 2015-11-25 14:14:15 CET
Thanks for taking care of this. In fact I never paid too much attention to it before, but I think the problem was already present for dovecot in mageia4 where I remember I sometime needed to start dovecot after a reboot (but as I use it on a machine that's is rarely switched off, I didn't do more research at that time)
Comment 3 David Walser 2015-11-25 14:16:26 CET
This exact issue started with Mageia 5, as the systemd change happened after Mageia 4.  I did notice that Fedora also had another patch before this one to try to force dovecot to wait longer to start, so maybe there was an issue with dovecot itself.
Comment 4 Herman Viaene 2015-11-27 10:44:48 CET
MGA-32 on Acer D620 Xfce
No installation issues.
I could not replicate the boot errors with the oldest rpm's in the repos: dovecot-2.2.13-5.mga5
Anyway, I updated to the 5.2 version and no problems there neither, so OK AFAICS.

CC: (none) => herman.viaene
Whiteboard: (none) => MGA5-32-OK

Comment 5 Bit Twister 2015-11-27 20:33:57 CET
(In reply to Nicolas Pomarède from comment #0)
> Description of problem:
> 
> Hello
> 
> this problem is in fact similar to bug #16642 for dhcpd.
> 
> On boot, for some reasons on my PC, it seems the network interface doesn't
> come up fast enough before dovecot.service is started.
> 
>
> In my case, the solution was to modify
> /usr/lib/systemd/system/dovecot.service and to change :
> 
> After=local-fs.target network.target
> to
> After=local-fs.target network-online.target
> 
> After this, dovecot starts successfully on each boot.
> 
> Maybe others services opening a listen socket at boot should be changed to
> use network-online.target (apache, spamd, ...) 

Not sure that is a good solution. I have modified my system to use systemd-networkd and disabled network.service and NetworkManager which gets me 20 second faster boot times.

Instead of network-online.target I would have to use systemd-networkd-wait-online.

If Mageia converts to systemd-networkd some time in the future all those service files would have to be changed again.

You might want to look through http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget

You might try backing out your change and running
 systemctl enable NetworkManager-wait-online.service
 systemctl --system daemon-reload

CC: (none) => bittwister2

Comment 6 David Walser 2015-11-27 20:47:30 CET
No, network-online is a generic target for when the network is up.  It doesn't matter which network service implementation you're using.  This was the correct change.  As long as upstream doesn't do something stupid again, it will remain correct.
Dave Hodgins 2015-11-29 22:56:24 CET

Keywords: (none) => validated_update
Whiteboard: MGA5-32-OK => MGA5-32-OK MGA5-64-OK advisory
CC: (none) => davidwhodgins, sysadmin-bugs

Comment 7 Nicolas Pomarède 2015-12-03 14:30:21 CET
I used dovecot-2.2.13-5.2.mga5.i586.rpm from update/testing and this works correctly now, seems good to be pushed to update/main in my case.
Comment 8 Mageia Robot 2015-12-05 00:32:15 CET
An update for this issue has been pushed to Mageia Updates repository.

http://advisories.mageia.org/MGAA-2015-0191.html

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.