Because of irregularities in the Earth's rate of rotation, time calculated using Earth's rotation drifts away from atomic time. Due to this, the International Earth Rotation and Reference Systems Service (IERS) introduced the concept of a leap second.
Because the Earth's rotation speed varies, UTC leap seconds are irregularly spaced and unpredictable. Insertion of each UTC leap second is usually decided about six months in advance by the IERS.
A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC). The IERS usually decides to apply a leap second whenever the difference between UTC and the mean solar time approaches 0.6 seconds.
A positive leap second is inserted between second
23:59:59 of a chosen UTC calendar date (the last day of a month, usually June 30 or December 31) and second
00:00:00 of the following date. This extra second is displayed on UTC clocks as
Unlike leap days, UTC leap seconds occur simultaneously worldwide (since it happens in UTC); for example, the leap second of December 31, 2016 23:59:60 UTC will be January 1, 2017 00:59:60 in Malta (Central European Time UTC +1) and January 1, 2017 08:59:60 in Japan (Japan Standard Time UTC +9) and December 31, 2016 18:59:60 in New York (Eastern Standard Time UTC -5).
2016's Leap Second
On 6th July 2016, the IERS announced that an extra second will be injected into UTC on December 31st 2016. This will be the 27th leap second introduced since this system of correction was implemented in 1972.
So, at the stroke of midnight UTC on New Year's Eve of 2016, an extra second will be introduced, effectively causing the last second of the day to last for two seconds. Time will advance from: 2016-12-31 23:59:58 UTC to 23:59:59 to 23:59:60 before reaching 2017-01-01 00:00:00 UTC.
Why should you care?
One of the worst impacts of the Leap Second is that programmers and system administrators are oblivious to it. It's very important to understand how the leap second works and how it might affect your software, infrastructure and business.
Most clocks do not support a leap second; they physically cannot allow the 60th second to happen. This is not really that important for personal computers or mobile phones, but it is critical for time sensitive applications like medical equipment, databases, GPSes (air traffic control, missile guidance systems), nuclear reactors, ongoing experiments, synchronized replication, etc...
Many big sites have fallen victims to the leap second bug; sites like reddit, Yelp, FourSquare and LinkedIn.
Inevitably, there are a variety of clocks working in a single system at a given time; the worst thing being that they don't all act the same:
- Some Linux kernels implement a one-seconds backwards jump instead of the extra
:60second, repeating the 59th second. RedHat has a great article on how to deal with Leap Second issues in Linux.
- Windows Time Servers ignore the NTP leap second signal and will sync to the correct time after the leap second.
- Some VMWare Appliances need to be updated to the latest version
- Old versions of Java, Tomcat and Cassandra have known issues as well
Handling a Leap Second
The three ways how to handle a leap second, in order of personal preference, are:
- Slew (smear) the leap second
- This would be the preferable way to handle the leap second.
- Google pioneered this concept in 2011. They configured their Stratum 2 NTP Servers not to set the Leap Indicator field, but rather lie about the time, modulating time over a time window
lie(t) = (1.0 - cos(pi * t / w)) / 2.0.
- This means that during the smear, Google's clocks will run slightly slower than usual. Each second of time marked by Google's servers will be about 13.9μs longer than an SI second.
- This is a brilliant solution and fortunately for us, on November 30th 2016, Google made their NTP Servers publicly available, which has leap smearing built right in.
- Step back the clock
- This is the default approach in Windows and most other Operating Systems.
- NTP Servers send out the Leap Indicator (LI) field which notify the Clock Services that a leap second will occur.
- The NTP Client, then, will repeat the 59th second twice, thus resolving the time difference with UTC.
- Ignore the leap second
- It is possible to ignore the leap second entirely. The clock will continue with the incorrect time until it is addressed through normal operation.