You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
9The problem is in detecting collisions — if we could detect them instantly, we would not release those that collided and regenerate a new one right away, so the caller would never even see the throw.Erik Eidt– Erik Eidt2024-01-15 23:04:48 +00:00Commented Jan 15, 2024 at 23:04
-
@ErikEidt - if you throw this kind of error once per your lifetime, you would be lucky man. So its fine to just risk it.libik– libik2024-01-16 11:03:39 +00:00Commented Jan 16, 2024 at 11:03
-
If you throw this error once in your lifetime, that’s too often. But anyway, check out whether throwing an exception (with absolutely untested handling) or just ignoring the collision is worse. It’s quite possible that a collision with another UUID generated ten years ago will have no negative effect at all.gnasher729– gnasher7292024-01-16 22:37:10 +00:00Commented Jan 16, 2024 at 22:37
-
2Even though the probability of randomly picking the same UUID twice is astronomically low, you usually have to carefully consider what would happen when there are collisions anyway, not "just risk it". Even if you throw an exception inserting the record, what state is the (distributed!) system in after that exception; is it valid, or vulnerable to attack? Are you sure that no other records were inserted assuming they were referring to the one that was rejected that are actually now referring to the other one that tried to use that id?Ben– Ben2024-01-17 02:21:17 +00:00Commented Jan 17, 2024 at 2:21
-
4Because collisions can happen due to clients that are erroneous or malicious, not just due to the RNG actually rolling the same UUID again. You generally can't assume the probability of that is near-zero (especially malicious clients). This point applies to schemes that guarantee uniqueness too though; if you can't assume all clients are non-malicious and bugfree, you have to deal with potential collisions anyway.Ben– Ben2024-01-17 02:22:18 +00:00Commented Jan 17, 2024 at 2:22
|
Show 2 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you