This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.

Time moved backwards error

Dovecot isn't very forgiving if your system's time moves backwards. There are usually two possibilities why it's moving backwards:

  1. You're running ntpdate periodically. This isn't a good idea.

  2. You're using some kind of a virtual server and you haven't configured it right (or it's buggy).

Moving time backwards might cause various problems (see below), so Dovecot versions older than v2.0 don't even try to handle the situation.

Time synchronization

There are two choices for synchronizing your clock:

  1. Use ntpd. It periodically checks the current time from NTP server and slows down or speeds up the clock if necessary. Unlike ntpdate, it doesn't just move the time forwards or backwards (unless the difference is large).

    • If the time difference is too large for ntpd and it "steps", then use "-x" as a command line option for ntpd or use "tinker step 0" in /etc/ntp.conf.

      • This shows up in logs as: ntpd[17697]: time reset -2.075483 s

  2. If ntpd doesn't work well (e.g. a bad network connection), you can use clockspeed or chrony as well.

If all else fails, you can just go and remove the error checking code from src/lib/ioloop.c. It's unlikely that anything will break badly, but you might get some errors logged once in a while.

In some systems ntpd/ntpdate is run at boot, but only after Dovecot has started. That can cause Dovecot to die immediately. If you have this problem, fix your init scripts to run ntpd/ntpdate first, before starting Dovecot. Also, seriously consider running ntp-wait before starting Dovecot.

Bugs/Issues

What about Daylight Saving/Summer time?

On Unix-like systems, time is stored internally as the number of seconds since January 1, 1970, 00:00:00 UTC (see Unix_time on Wikipedia); concepts such as time zones and daylight saving time are applied in user space by the C library, and will normally not have an impact on Dovecot's behavior.

Dovecot shouldn't just die!

Dovecot v2.0 finally tries to handle this a bit more gracefully. Its behavior when time moves backwards is:

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:

While killing mail processes doesn't fully solve any of those issues, they're at least less likely to happen then.

TimeMovedBackwards (last edited 2011-08-10 12:30:11 by mail02)