PCPartPicker

  • Log In
  • Register

The 23 hour bug

Forum Search

Guidelines

  • Be respectful to others
  • No spam
  • No NSFW content
  • No piracy or key resellers
  • No link shorteners
  • Offensive content will be removed

Topic

philip 37 months ago

Found it and fixed it finally. Was pretty simple in retrospect.

We run multiple frontends behind a load balancer. The date on the frontends varies by a bit between them. The largest delta is about two minutes. It's not particularly critical that they be perfectly in sync with each other.

What was happening was that if you posted a comment and it posted on a frontend that was ahead two minutes, there was a chance that later rendering that comment you'd render it on a system that was two minutes behind the system that posted it. So the comment would effectively be in the future. The way our "format time delta" function worked, if you passed in a negative time delta it'd print out "23 hours ago". Since the largest time delta was about 2 minutes, you'd have a reasonable chance posting a comment to see that bug during the first two minutes after that comment / topic / whatever was posted.

The simple short-term fix was to just treat negative time differences as no time difference (and say it was "0 seconds ago"). Longer term we'll probably do a better job of syncing up the clocks between the systems.

Comments Sorted by:

FH100 2 points 37 months ago

So you guys weren't working on some time traveling machine? Darn, lost that bet.

Good to learn what caused this. Thanks.

S0nny_WarBucks58 3 Builds 1 point 37 months ago

Awesome, it is cool that you fixed it!

GentlemanShark 1 Build 1 point 37 months ago

But why 23?

living180 staff 2 Builds 5 points 37 months ago

It's because of a quirk in the way Python stores negative time deltas. Negative two minutes is stored as negative one day, plus twenty-three hours, plus fifty-eight minutes. When we converted that to a human readable string, the code checked the number of days first, and skipped it because it was less than one (-1 < 1), then checked the hours, found 23, and thus reported "23 hours ago". The fix as Philip indicated was simply to skip the normal logic and report "0 seconds ago" for any negative time delta.

Xorex64 1 point 37 months ago

iTS A NEW STAFFER (for me, ive never seen you before)

living180 staff 2 Builds 3 points 37 months ago

Yes, as Philip said, I've been around awhile. I just tend to spend more time behind the scenes working on making the site great, though I do occasionally pop up on the forums.

philip staff submitter 10 Builds 1 point 37 months ago

Nope. He's definitely not new. He came on board after manirelli but before everyone else.

Xorex64 1 point 37 months ago

For me

[comment deleted by staff]
living180 staff 2 Builds 3 points 37 months ago

Thanks jipster! It's definitely a fun and rewarding job.

[comment deleted]
Brood550 1 Build 1 point 37 months ago

Someone was a big Jordan fan. ;)

[comment deleted]
rosswalker 1 Build 1 point 37 months ago

Woooooo

Siwini 1 point 37 months ago

I like the time machine theory, but I really do appreciate an explanation that I could understand.

Phillip.Phillip 1 point 37 months ago

My comment still says "23 hours ago" if you look at it

:P

ComputerSaysNo 1 Build 1 point 37 months ago

Great job guys, keep it up.

ewhac 2 Builds 1 point 37 months ago

We run multiple frontends behind a load balancer. The date on the frontends varies by a bit between them. [ ... ]

Um... You've heard of ntpd, right?

[comment deleted]
[comment deleted]
[comment deleted]
[comment deleted]