Closed broofa closed 2 years ago
Any time source which yields non-monotonic times doesn't satisfy the requirement:
Implementations SHOULD use the current timestamp from a reliable source to provide values that are time-ordered and continually increasing
So I reckon this is out-of-scope?
@peterbourgon, the point is just calling out an edge case where we do know a timestamp may naturally go backwards and provide some verbiage around how to handle this in the best practices section.
@broofa
Fair, a note that time sources must be monotonic in the docs should be good.
More information: https://docs.ntpsec.org/latest/leapsmear.html provides a good description of the problem and possible solutions from the NTP perspective, and also provides guidance on when systems implement leap seconds via clock regression v. pausing v. "smearing". (E.g. if an app has legal requirements for using "correct" time, pausing and smearing should not be used.)
@kyzer-davis Mentioning this in the granularity and fuzzing sections makes sense. Additionally, it's probably appropriate to mention this in the section on dedicated counter length. For systems that don't implement leap smearing users will need to anticipate time intervals of up to ~1 second (real time) where the timestamp doesn't change, regardless of the normal timestamp resolution, and size the counter accordingly.
the number of ids that occur during that interval may be 1000x more than expected, leading to a counter overflow
This must be avoided at all costs. UUIDs are not intended to be a source of precise UTC time (see section "Opacity"). Therefore, the timestamp of UUIDs may well differ from UTC by several seconds. The UUID generator MUST roll back all known leap seconds since the Unix Epoch. The leap seconds become known ahead of time, so this can be provided.
With a strong desire, it is possible to calculate UTC time from such a timestamp, knowing when leap seconds were added.
We have discussed (at length) how important monotonicity is in timestamps. Specifically, the draft currently states:
However this may be at odds with Unix Time where leap-seconds are involved. For example, an uncompensated unix time clock may regress thusly:
NTP addresses this case by "pausing" the clock during a leap second so that the time remains monotonic, but even that is not without issue. For example, if the
counter
field width is selected to handle a certain maximum number of ids being generated every millisecond but the clock pauses for one or more seconds, the number of ids that occur during that interval may be 1000x more than expected, leading to a counter overflow.I don't have text to propose at this time. 'Just noting this as an issue that we might want to address.