Ask HN: 我们刚刚遇到了一个真实的 UUID v4 碰撞...

3作者: mittermayr2 个月前
今天早上,我们的系统因为数据库中出现了重复的 UUID (v4) 而报错。我检查了一下,以为可能是双重插入之类的 bug,但结果并非如此。<p>在 2025 年(大约一年前),数据库中就已经存在了相同的 UUID v4:<p>b6133fd6-70fe-4fe3-bed6-8ca8fc9386cd<p>我们使用的是这个库: https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;uuid<p>大家都说这种情况在技术上是不可能发生的,永远不会出现。<p>但我们对 UUID 并没有做任何特殊处理,只是生成它们然后插入到 SQL 数据库中,而且数据量也不大... 数据库里大约有 15000 条记录。<p>有人遇到过这种情况吗?!
查看原文
This morning, our system threw an error because of a duplicate UUID (v4) in the database. I checked, thinking it may have been a double-insert bug or something, but no.<p>In 2025 (about a year ago), that same UUID v4 was already in the database:<p>b6133fd6-70fe-4fe3-bed6-8ca8fc9386cd<p>We&#x27;re using this: https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;uuid<p>I mean, everyone says this is technically impossible, and it will never happen.<p>But there&#x27;s no magic we&#x27;re doing with our UUIDs, we&#x27;re generating them to insert into SQL, and it&#x27;s not even high-volume... the database has about 15.000 records.<p>Has that ever happened to anyone?!