Leap Seconds Are Ending #cloudflare #leapsecond #programming
Read the Portuguese translation →
Author: Better Stack · Watch on YouTube
Video authored by the channel shown, not by IANIA; all rights belong to the creator. Transcript and summary generated automatically; the original-language content is preserved.
Original language: English
Original video: Leap Seconds Are Ending #cloudflare #leapsecond #programming · Channel: Better Stack · 02:09 · Watch on YouTube
Topics: Software engineering with AI, AI infrastructure and hardware
Summary
Section titled “Summary”Leap seconds were introduced in 1972 to keep UTC aligned with the uneven rotation of the Earth, but handling them has repeatedly caused software failures. The video describes how a leap second triggered a Linux kernel bug that took Reddit offline in 2012 and how a backwards clock caused Cloudflare’s DNS to fail in 2017. Google and Meta avoid the sudden jump by gradually smearing the extra second across several hours. A decision made in 2022 was given an implementation date: from May 20, 2027, UTC will no longer add or skip seconds. However, a future need to subtract a second has never been tested at large scale.
Key points
Section titled “Key points”- Since 1972, 27 leap seconds have been added to UTC to keep it aligned with Earth’s uneven rotation.
- Most computers cannot represent 23:59:60, and Unix time assumes each day is exactly 86,400 seconds.
- Linux handles a leap second by stepping the clock back one second, so 23:59:59 occurs twice.
- In 2012, a Linux kernel bug caused programs waiting for a moment to wake repeatedly and max out the CPU, taking Reddit down for 30 to 40 minutes.
- In 2017, Cloudflare’s DNS failed after its Go code calculated a negative lookup duration when the clock moved backwards.
- Google and Meta smear leap seconds by running their clocks slightly slow for a few hours.
- From May 20, 2027, UTC will keep ticking without seconds being added or skipped.
- The Earth has recently been spinning faster, raising the possibility of a negative leap second, which would jump from 23:59:58 to midnight.
- The video says the resolution put the chance of needing such a second by 2035 at 30%, and that removing one has not been tested at large scale.
Chapters
Section titled “Chapters”| Start | Chapter | Summary |
|---|---|---|
| 00:00 | What leap seconds are | The video explains why leap seconds were introduced and how computers handle the extra second. |
| 00:32 | Software failures caused by time moving backwards | It recounts the leap-second-related Linux kernel bug that took Reddit offline and Cloudflare’s 2017 DNS failure. |
| 01:04 | Clock smearing and the decision to end leap seconds | The video describes how Google and Meta smear leap seconds before giving the date UTC will stop adding or skipping them. |
| 01:36 | The risk of a negative leap second | It discusses the possibility of subtracting a second and the lack of large-scale testing for removing one. |
Quotes
Section titled “Quotes”This has happened 27 times. — 00:00
So, while the world added a second, from your code’s point of view, time actually went backwards — 00:32
the root cause of this one was just the belief that time cannot go backwards. — 01:04
From the 20th of May 2027, UTC will just keep ticking with no seconds added or skipped. — 01:36
Meta says the impact of removing one has never been tested on a large scale. — 02:09
Concepts and entities
Section titled “Concepts and entities”leap second, UTC, Unix time, Linux kernel, Reddit, Cloudflare, Google, Meta, General Conference of Weights and Measures, smear
Full transcript (original language)
Section titled “Full transcript (original language)”00:00 After more than 50 years, they’re scrapping the leap second, which is the exact second that once took down Reddit and broke Cloudflare’s DNS. For a quick refresher, our clocks run on atomic time, but the Earth doesn’t spin perfectly evenly. So, since 1972, every so often, an extra second gets added to UTC to keep the two lined up. This has happened 27 times. On a normal night, the clock will go from 23:59:59 to midnight, but on a leap second night, it goes 23:59:59, 23:59:60, and then midnight. Trouble is, most computers can’t show 23:59:60,
00:32 and Unix time assumes that every day is exactly 86,400 seconds. So, Linux actually handles this by stepping the clock back 1 second and playing 23:59:59 twice. So, while the world added a second, from your code’s point of view, time actually went backwards, and pretty much every time this has happened, something has broken. In 2012, that jump hit a bug in the Linux kernel. Programs that were told to wait a moment kept waking up instantly over and over and maxed out the CPU. This caused Reddit to go down for 30 to 40 minutes. Then, on New Year’s Day 2017, Cloudflare’s DNS
01:04 fell over because their Go code actually timed each lookup by taking the time at the end and subtracting the time at the start. If the clock goes backwards a second in the middle, Cloudflare says the perceived resolution time will be negative and rand.Int63N probably panics if the argument is negative. So, the root cause of this one was just the belief that time cannot go backwards. Google and Meta actually handle this in a different way. They don’t do a leap second at all. They smear it, running their clocks very slightly slow for a few hours, so the time never jumps. This week, though, it is finally over. The General Conference of Weights and Measures, which meets every 4 years to
01:36 decide things like what a kilogram is, already agreed in 2022 to scrap the leap second, but this week, they put a date on it. From the 20th of May 2027, UTC will just keep ticking with no seconds added or skipped. And there was actually a scarier reason to do this. Lately, the Earth has actually been spinning a bit faster, so instead of adding a second, we might needed to take one away, jumping straight from 23:59:58 to midnight. And the resolution put the that we’d actually need one of these by 2035 at 30%. But, this has never been done before. Every leap second so far has added time, and software still got
02:09 that wrong. Meta says the impact of removing one has never been tested on a large scale. Have you ever been bitten by a time bug? Let me know in the comments, and subscribe for more dev news every week.