You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 1, 2024. It is now read-only.
Under JRuby I am calling UUID.generate quite often. I see a case in my logs where two successive calls returns the same UUID. Looking at the code, I see this comment:
# The clock must be monotonically increasing. The clock resolution is at# best 100 ns (UUID spec), but practically may be lower (on my setup,# around 1ms). If this method is called too fast, we don't have a# monotonically increasing clock, so the solution is to just wait.## It is possible for the clock to be adjusted backwards, in which case we# would end up blocking for a long time. When backward clock is detected,# we prevent duplicates by asking for a new sequence number and continue# with the new clock.
Judging by the comment, I assume that it is possible that a backward clock could be detected twice in a row, so asking for a new sequence number in that situation will still generate the same UUID when UUID.state_file=nil. If this assumption is correct, would it be reasonable to randomize the next sequence number?