[Dovecot] old master.pid prevents dovecot startup

Michael dovecot2008 at mth.com
Wed Jan 16 18:34:30 EET 2008


Summary
=======
After an unclean shutdown the file /var/run/dovecot/master.pid remained
behind. This prevented dovecot from starting, and gave a misleading error
message.

To be more resilient and fault-tolerant, I recommend that dovecot also
check the validity of the PID in /var/run/dovecot/master.pid in order to
determine whether or not another dovecot process is running.

Detail
======

In testing out my automatic UPS shutdown I inadvertently shut down my
system uncleanly ... oops!

As the system rebooted, I saw that dovecot did not start properly, with an
error message:
 Fatal: Invalid configuration in /etc/dovecot.conf

After the system came up, I tried to start dovecot manually. Turns out
that there was an invalid PID in /var/run/dovecot/master.pid

-----

[root at mykiss5 mth]# service dovecot start
Starting Dovecot Imap: Error: Dovecot is already running with PID 1965
(read from /var/run/dovecot/master.pid)
Fatal: Invalid configuration in /etc/dovecot.conf
                                                           [FAILED]
[root at mykiss5 mth]# ps 1965
  PID TTY      STAT   TIME COMMAND
[root at mykiss5 mth]# rm /var/run/dovecot/master.pid
rm: remove regular file `/var/run/dovecot/master.pid'? y
[root at mykiss5 mth]# service dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[root at mykiss5 mth]# service dovecot stop
Stopping Dovecot Imap:                                     [  OK  ]
[root at mykiss5 mth]# service dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[root at mykiss5 mth]# dovecot --version
1.0.7
[root at mykiss5 mth]#

-----

This leads me to believe that dovecot is only checking for the existance
of /var/run/dovecot/master.pid. It seems to me that it would be more
fault-tolerant if it also checked the validity of the PID that is in
/var/run/dovecot/master.pid.


Michael





More information about the dovecot mailing list