KAFKA-20072 Don't generate IDs with hyphens#21313
Conversation
|
@mumrah Hello, are the current minimal changes sufficient or do we need to optimize the |
| public static Uuid randomUuid() { | ||
| Uuid uuid = unsafeRandomUuid(); | ||
| while (RESERVED.contains(uuid) || uuid.toString().startsWith("-")) { | ||
| while (RESERVED.contains(uuid) || uuid.toString().contains("-")) { |
There was a problem hiding this comment.
Note that the probability of rejecting a generated uuid rises from 1.56% (= 1/64) to 30.5% (= 1 - (63/64)**19 * 15/16, taking into account fixed bits in version 4 uuids). The new p99 number of rejections is ~3.88 (was 1.11) which I think is not too bad.
There was a problem hiding this comment.
30% failure rate for a general utility class is really high and I don't think it makes sense. Uuids are occasionally used in cases where performance matters. Also, the reasoning for the change is unclear.
There was a problem hiding this comment.
Thanks, @ijuma -- that's a very good point about performance! I did check through fetch/produce paths originally, but of course that doesn't protect us from future usages (or things not caught during the review).
I'll file a patch shortly that makes this new behavior opt-in.
As to the reasoning, the original Jira I wrote was about issues with double-clicking on IDs. Really it's just meant to be a small quality of life improvement.
|
We use Uuid on the client side for group member ids. If I understand correctly, hyphens don't affect the behavior, Uuids with hyphens will continue to work as before, and this is only a slight usability improvement. Should we still document it, for example in the protocol page, as a recommendation for 3rd party clients? |
|
@mimaison indeed this won't affect existing IDs or externally generated ones that "violate" the rule. I'm not sure if we document the leading underscore preference, but it seems like a reasonable inclusion (e.g., "clients should generate UUIDs without hyphens). |
|
@mimaison or @squah-confluent any further feedback here? |
|
I don't see an update to the docs in the changes. |
|
The code change is fine by me. The current documentation change raises some questions. It would be nice to improve the wording.
|
|
@squah-confluent Thanks for your comment. |
|
This PR is being marked as stale since it has not had any activity in 90 days. If you If you are having difficulty finding a reviewer, please reach out on the [mailing list](https://kafka.apache.org/contact). If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed. |
The
Uuid#randomUuidmethod has been modified to avoid generating UUIDscontaining hyphens.