Hacker News new | ask | show | jobs
by devmonk 5691 days ago
Curious about this in snowflake (mentioned in slides):

https://github.com/twitter/snowflake/blob/master/src/main/sc...

  def nextId(): Long = synchronized {
    var timestamp = timeGen()

    if (lastTimestamp > timestamp) {
        log.warning("clock is moving backwards. Rejecting requests until %d.", lastTimestamp);
        throw new InvalidSystemClock("Clock moved backwards. Refusing to generate id for %d milliseconds".format(lastTimestamp - timestamp));
    }
Does that mean that the inability to tweet grinds to a halt if the system clock gets set back? That could be a problem whenever the server time is being sync'd with the time server and is running ahead (or if time server goes down/connection goes down- it happens), etc. I know there would be other issues too, but this seems a little fishy.
1 comments

> Does that mean that the inability to tweet grinds to a halt if the system clock gets set back

Not necessarily, their applications most likely have some retry logic which runs when an InvalidSystemClock exception is caught.

Retry would work for small time differences, but would mean greater delay (and subsequent "I give up"), if the system clock were to be set backwards a substantial amount.