RC RANDOM CHAOS

UUIDv7's Timestamp and Ordering Problems

· via Hacker News

Original source

UUIDv7: Timestamps aren’t time-ordered and other oddities

Hacker News →

UUIDv7 is widely promoted as providing monotonically increasing identifiers with creation timestamps and strong unguessability. However, RFC 9562 permits implementations significant flexibility in handling edge cases, meaning none of these properties are strictly guaranteed. The only reliable property is uniqueness.

The embedded timestamp often diverges from actual creation time because the RFC allows implementations to modify it when managing counter overflow. Under sustained load, the timestamp can accelerate far ahead of the system clock. Python’s standard library implementation demonstrates this: when a clock jumps backward, the generator prevents timestamp reversions by continuously incrementing, causing the embedded timestamp to race far ahead of real time as each ID is generated.

Strict monotonic ordering isn’t achievable across nodes—a problem understood since the 1970s due to clock synchronization limitations. Even single-node implementations without sub-millisecond counters produce out-of-order sequences. Most implementations don’t persist the last-used timestamp to storage, so they generate out-of-order IDs following process restarts when clocks have jumped backward. Additionally, the embedded timestamp leaks creation metadata that applications may intentionally conceal. While loosely-ordered IDs remain practical for many systems, developers should avoid assumptions about strict monotonicity or timestamp accuracy.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.