{"id":14308,"date":"2015-06-30T08:51:12","date_gmt":"2015-06-30T06:51:12","guid":{"rendered":"https:\/\/blog.trifork.com\/?p=14308"},"modified":"2015-06-30T08:51:12","modified_gmt":"2015-06-30T06:51:12","slug":"a-wrinkle-in-time","status":"publish","type":"post","link":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/","title":{"rendered":"A wrinkle in time"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14313 aligncenter\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg\" alt=\"Leap second\" width=\"460\" height=\"307\" srcset=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg 460w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200-300x200.jpg 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/p>\n<p>I clearly remember the\u00a0morning of Sunday July\u00a01, 2012, almost three years ago. I was at church, actually, when I got a call from one of our clients: &#8220;The website doesn&#8217;t seem to be working.&#8221; All I could check at that point was that, indeed, the website was not responding. So I called our sysadmin, who found that even SSH-ing\u00a0into the machine running the site was taking much longer than usual. Finally, restarting everything solved the problem, but we were still unsure about what had happened.<\/p>\n<p>As we found out later, it was\u00a0related to the leap second, a phenomenon I had not even heard of until then.<!--more--><\/p>\n<h2>The leap second<\/h2>\n<p>The definition of our day &#8211; 24 hours of 60 minutes of 60 seconds &#8211; is supposed to match a single full\u00a0rotation\u00a0of the earth.\u00a0As it turns out, our timekeeping is a bit to rigid for our swiftly tilting planet. It&#8217;s actually slowing down. So every now and then, we need to account for the difference between our timekeeping and reality, or in a couple of thousand years, we&#8217;d have sunrise at noon and sunset at midnight. This is what the leap second does.<\/p>\n<p>So in the night from June 30, 2012 to July 1, 2012 at midnight UTC, an extra second was added. That&#8217;s right: 23:59:<strong>60<\/strong>. And it will happen again tonight.<\/p>\n<h2>What went wrong last time<\/h2>\n<p>As it turned out, our client&#8217;s website wasn&#8217;t the only one affected. In fact, companies like <a href=\"http:\/\/www.reddit.com\/\" target=\"_blank\" rel=\"noopener\">Reddit<\/a> and <a href=\"http:\/\/www.linkedin.com\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a> suffered from the same issues. The details are described fairly well in <a href=\"http:\/\/www.wired.com\/2012\/07\/leap-second-glitch-explained\/\" target=\"_blank\" rel=\"noopener\">this article.<\/a>\u00a0In our case, just like Reddit&#8217;s, it was an unfortunate mix of a bug in the Linux kernel, our use of the Network Time Protocol, and Java. Basically the kernel adjusted for the leap second but due to the combination with NTP this caused the Java processes to start spinning and using up all of the CPU.<\/p>\n<h2>June 30, 2015 23:59:60<\/h2>\n<p>Tonight we will get another leap second. For you folks in the US it will be on the evening of the 30th. For us in Europe, in the early hours of July 1. If your systems start acting strange around that time, suspect the leap second!<\/p>\n<h2>Try it out<\/h2>\n<p>The Joda date library explicitly <a href=\"http:\/\/joda-time.sourceforge.net\/faq.html#leapseconds\" target=\"_blank\" rel=\"noopener\">doesn&#8217;t support leap seconds<\/a>\u00a0(you will get an exception if you try to instantiate a <code>DateTime<\/code>\u00a0with 60 for the &#8220;seconds&#8221; value). The <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/Date.html\" target=\"_blank\" rel=\"noopener\">Java java.util.Date API documentation<\/a> seems to indicate it does, but if you try it, it doesn&#8217;t seem to. For example, the year 1995 had an extra second on December 31, but Java ignores it:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nDateFormat df = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;);\ndf.setTimeZone(TimeZone.getTimeZone(&quot;UTC&quot;));\nDate beforeLeap = new Date(820454399000L); \/\/ 31-12-1995 23:59:59 Z\nSystem.out.println(df.format(beforeLeap));\nDate leap = new Date(820454400000L);\nSystem.out.println(df.format(leap));\nDate afterLeap = new Date(820454401000L);\nSystem.out.println(df.format(afterLeap));\n<\/pre>\n<p>Output:<\/p>\n<pre>1995-12-31 23:59:59\n1996-01-01 00:00:00\n1996-01-01 00:00:01\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Does your programming language of choice support the leap second? Leave a comment with\u00a0some code that demonstrates it!<\/p>\n<h2>Links<\/h2>\n<ul>\n<li><a title=\"\u2018Leap second\u2019 bug wreaks havoc across the web\" href=\"http:\/\/www.wired.com\/2012\/07\/leap-second-bug-wreaks-havoc-with-java-linux\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.wired.com\/2012\/07\/leap-second-bug-wreaks-havoc-with-java-linux\/<\/a><\/li>\n<li><a title=\"On Tuesday, the world gets a \u2018leap\u2019 second. Are we all gonna die?\" href=\"http:\/\/www.washingtonpost.com\/news\/speaking-of-science\/wp\/2015\/06\/29\/on-tuesday-the-world-gets-a-leap-second-are-we-all-gonna-die\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.washingtonpost.com\/news\/speaking-of-science\/wp\/2015\/06\/29\/on-tuesday-the-world-gets-a-leap-second-are-we-all-gonna-die\/<\/a><\/li>\n<li><a title=\"The inside story of the extra second that crashed the web\" href=\"http:\/\/www.wired.com\/2012\/07\/leap-second-glitch-explained\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.wired.com\/2012\/07\/leap-second-glitch-explained\/<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Leap_second\" target=\"_blank\" rel=\"noopener\">https:\/\/en.wikipedia.org\/wiki\/Leap_second<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I clearly remember the\u00a0morning of Sunday July\u00a01, 2012, almost three years ago. I was at church, actually, when I got a call from one of our clients: &#8220;The website doesn&#8217;t seem to be working.&#8221; All I could check at that point was that, indeed, the website was not responding. So I called our sysadmin, who [&hellip;]<\/p>\n","protected":false},"author":50,"featured_media":14313,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[337,31],"tags":[],"class_list":["post-14308","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-from-the-trenches","category-java"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A wrinkle in time - Trifork Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A wrinkle in time - Trifork Blog\" \/>\n<meta property=\"og:description\" content=\"I clearly remember the\u00a0morning of Sunday July\u00a01, 2012, almost three years ago. I was at church, actually, when I got a call from one of our clients: &#8220;The website doesn&#8217;t seem to be working.&#8221; All I could check at that point was that, indeed, the website was not responding. So I called our sysadmin, who [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Trifork Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-30T06:51:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"460\" \/>\n\t<meta property=\"og:image:height\" content=\"307\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Frans Flippo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Frans Flippo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/\",\"url\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/\",\"name\":\"A wrinkle in time - Trifork Blog\",\"isPartOf\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg\",\"datePublished\":\"2015-06-30T06:51:12+00:00\",\"author\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/a3ee7a945951fa1cff33a723a2fc9621\"},\"breadcrumb\":{\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage\",\"url\":\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg\",\"contentUrl\":\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg\",\"width\":460,\"height\":307,\"caption\":\"Leap second\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/trifork.nl\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A wrinkle in time\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/trifork.nl\/blog\/#website\",\"url\":\"https:\/\/trifork.nl\/blog\/\",\"name\":\"Trifork Blog\",\"description\":\"Keep updated on the technical solutions Trifork is working on!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/trifork.nl\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/a3ee7a945951fa1cff33a723a2fc9621\",\"name\":\"Frans Flippo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/75ba3422fb6b7c9dae6d833b934e3823?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/75ba3422fb6b7c9dae6d833b934e3823?s=96&d=mm&r=g\",\"caption\":\"Frans Flippo\"},\"url\":\"https:\/\/trifork.nl\/blog\/author\/fransf\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A wrinkle in time - Trifork Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/","og_locale":"en_US","og_type":"article","og_title":"A wrinkle in time - Trifork Blog","og_description":"I clearly remember the\u00a0morning of Sunday July\u00a01, 2012, almost three years ago. I was at church, actually, when I got a call from one of our clients: &#8220;The website doesn&#8217;t seem to be working.&#8221; All I could check at that point was that, indeed, the website was not responding. So I called our sysadmin, who [&hellip;]","og_url":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/","og_site_name":"Trifork Blog","article_published_time":"2015-06-30T06:51:12+00:00","og_image":[{"width":460,"height":307,"url":"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg","type":"image\/jpeg"}],"author":"Frans Flippo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Frans Flippo","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/","url":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/","name":"A wrinkle in time - Trifork Blog","isPartOf":{"@id":"https:\/\/trifork.nl\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage"},"image":{"@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage"},"thumbnailUrl":"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg","datePublished":"2015-06-30T06:51:12+00:00","author":{"@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/a3ee7a945951fa1cff33a723a2fc9621"},"breadcrumb":{"@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#primaryimage","url":"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg","contentUrl":"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/06\/leap-second-1200.jpg","width":460,"height":307,"caption":"Leap second"},{"@type":"BreadcrumbList","@id":"https:\/\/trifork.nl\/blog\/a-wrinkle-in-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/trifork.nl\/blog\/"},{"@type":"ListItem","position":2,"name":"A wrinkle in time"}]},{"@type":"WebSite","@id":"https:\/\/trifork.nl\/blog\/#website","url":"https:\/\/trifork.nl\/blog\/","name":"Trifork Blog","description":"Keep updated on the technical solutions Trifork is working on!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/trifork.nl\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/a3ee7a945951fa1cff33a723a2fc9621","name":"Frans Flippo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/75ba3422fb6b7c9dae6d833b934e3823?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/75ba3422fb6b7c9dae6d833b934e3823?s=96&d=mm&r=g","caption":"Frans Flippo"},"url":"https:\/\/trifork.nl\/blog\/author\/fransf\/"}]}},"_links":{"self":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/14308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/users\/50"}],"replies":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/comments?post=14308"}],"version-history":[{"count":0,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/14308\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media\/14313"}],"wp:attachment":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media?parent=14308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/categories?post=14308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/tags?post=14308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}