Remix.run Logo
samdhar 3 hours ago

The math says no. UUID v4 has 122 bits of randomness, so collision probability for 15K records is N²/(2·2^122) ≈ 2·10^-29. That's somewhere around "fewer collisions per universe lifetime than atoms in your liver." Whatever you're seeing, the culprit is overwhelmingly somewhere else.

Things to check, in descending order of how likely they actually are:

1. Data import / migration / backup restore, perhaps? Did anyone load a CSV, run a seed script, restore a snapshot, or copy rows between environments at any point in the last year? This is what "duplicate UUID" is in 99% of cases. Check git on migrations, ops history on the DB, and ask anyone who might have been moving data around.

2. Application retry / rollback bug maybe? Code path that generates a UUID, attempts insert, fails on constraint violation, retries with the same UUID variable still in scope. Check whether UUID generation lives inside or outside the retry boundary.

3. Older versions of the uuid package in certain bundler environments would fall back to Math.random() instead of crypto.getRandomValues(). What version are you on? Anything <4.x is suspect; modern v8+/v9+ uses crypto everywhere correctly.

4. Could also be a process fork bug. If a UUID generator runs in a child process spawned from a parent that already used the PRNG, the entropy state can get copied. Rare in Node specifically, more historical in old Python/Ruby setups.

If you've ruled all of those out and the row really was generated independently a year apart via crypto.getRandomValues, go buy a lottery ticket. But it's almost certainly cause #1.

uncircle an hour ago | parent | next [-]

Statistically speaking, does extremely unlikely mean impossible? If it were replicable I'd raise my eyebrow, otherwise it's fair game, no?

As someone that enjoys the unterminable complaints about RNG in the video game scene, I would never trust any human's rationalization of random outcomes.

mschild an hour ago | parent | next [-]

> Statistically speaking, does extremely unlikely mean impossible?

No, it means extremely unlikely. Collisions can occur, as op just found out, but the chances are so abysmally small that most people don't care.

Any application I have worked on, I always had a pre-save check to see if the UUID was already present and generate a new one if it was. Don't think it ever triggered unless a bug was introduced somewhere but good practice anyway.

nubg an hour ago | parent | prev [-]

You are replying to an AI bot

harperlee an hour ago | parent [-]

Would be cool to have a plugin that shows % of bot per user, based on their history of comments.

ashleyn an hour ago | parent | prev | next [-]

There could be a problem with the way the system generates entropy for randomness.

nubg an hour ago | parent | prev [-]

Question to fellow HNers, do you recognize that this comment was written by AI?

prakka an hour ago | parent | next [-]

No, to be honest. However, as soon as it was pointed out, I checked again and it made sense.

In my opinion, these kind of intuitions have to grow over time. And every time it’s pointed out, you learn. So please, keep pointing it out :).

piva00 10 minutes ago | parent | prev | next [-]

Yes but as a feeling (hunch?) not as something my brain analysed and reached a conclusion.

Weird how I'm already somewhat conditioned to spot it on a intuitive level.

tirutiru an hour ago | parent | prev | next [-]

I did not. Post-conditioning by your comment and the other one,I can see some signs such attempting to be unusually comprehensive. The 'atoms in your liver' could be an awkward human trying to be poetic about scales.

I still don't see idiomatic markers of AI so that's scary if your claim is correct.

nottorp 37 minutes ago | parent | prev | next [-]

Interesting enough, I skipped it when scrolling through the comments the first time. I think I instinctually do that to most karma whoring comments, no matter if manual or LLM generated.

Only noticed it because I did another pass and saw the replies talking about "AI".

uncircle an hour ago | parent | prev | next [-]

I guess not, and I feel dirty now. I'm logging off for the day.

mschild an hour ago | parent | prev | next [-]

Kind of. It reads a bit too much like tech support you'd get when asking one for help.

an hour ago | parent | prev | next [-]
[deleted]
ssenssei an hour ago | parent | prev | next [-]

when it started going on about all the different cases in the second bullet point... yeah

speedgoose an hour ago | parent | prev [-]

Yes, stupid comparison with atoms in the liver and a bullet list below? I stopped reading.

35 minutes ago | parent [-]
[deleted]