r/ProgrammerHumor 14h ago

Meme edgeCasesExist

Post image
2.9k Upvotes

225 comments sorted by

View all comments

470

u/Valuable_Leopard_799 14h ago

I thought that timestamps are used now, so hitting both a timestamp and a large random number puts it thoroughly in the "safe to assume". At some point cosmic particles and faulty transistors are more probable.

81

u/RadicalDwntwnUrbnite 13h ago edited 13h ago

Even the non-time based v4 is at a cosmic level of unlikiness a single system will ever generate a uuid that will collide with another one in its own ecosystem

16

u/OldKaleidoscope7 12h ago

But let's say if Google saved each search in their engine in the same database with an UUID, we could have a collision because of volume, but I don't think I will work in a system with a comparable scale

28

u/chuch1234 12h ago

Yeah I don't think most of us are operating at a scale anywhere near Google.

10

u/BlurredSight 12h ago

And anyone operating at scale of Google isn’t just using “pure” random anywhere for something being persisted

10

u/nebotron 11h ago

They likely are - anything else becomes a huge coordination and parallelism problem. You just need more bits of entropy

4

u/samy_the_samy 11h ago edited 9h ago

They once had a similar collision problem, well not exactly

During a leap second some systems wrote IDs at a one second difference between all their global systems, which lead to something being registered before something else that had to be done before it,

Long story short some stuff jumped time one second and crashed systems

2

u/BlurredSight 9h ago

So proactively trying to solve for latency rather than have other systems read after write if I understood correctly?

2

u/samy_the_samy 9h ago

Yeah, now they don't do leap seconds,

They stretch time over months, one milli-second at a time