Last days i was receiving a notice at my email from cpanel’s monitor service that imap was failing. The exact message was :
imap failed @ 'time'. A restart was attempted automagically.
Service Check Method: [check command]
Number of Restart Attempts: 1
Cmd Service Check Raw Output: dovecot is not running
I was getting this message once a day, everyday, same time. I started digging at the logs and found out that at the time i had the failure there was a script running. The script was upcp and this was for updating cpanel.
I also found the entry below at
dovecot: dovecot: Fatal: Time just moved backwards by 6 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards
So the problem was with the clock skewing backwards and since dovecot is time sensitive it had troubles running smoothly.
From dovecot’s wiki :
Dovecot v2.0 finally tries to handle this a bit more gracefully. Its behavior when time moves backwards is:
Existing imap and pop3 processes either sleep or die, just like with older versions
Master process stops creating new processes until either the original time is reached, or after a maximum wait of 3 minutes.
Other processes log a warning, but do nothing else.
Timeouts are updated so that the timeout is executed approximately at the original intended time.
Dovecot v2.0 also notices when time unexpectedly jumps forwards. In that situation it logs a warning and also updates timeouts.
The reason why imap/pop3 processes get killed and new ones can't be created for a while is to avoid problems related to timestamps. Some issues are:
Uniqueness of Maildir filenames and dbox global unique identifiers relies on a growing timestamp
Dotlock files' staleness is detected by looking at its mtime.
Timestamps are stored internally all around in memory (as well as in index files) and compared to current time. Those checks may or may not be buggy if current time shrinks.
The solution i tried and for now it seems that it’s working is to install and enable the ntp protocol so as to syncronize the time and not have that much clock skew.
Just for the record :
yum install ntp
chkconfig ntpd on
Sources i used : 1