[Improvement] Switch to UUID v1 to avoid collision
- Dominant language
- Scala
- Stars
- 2.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
### Search before asking
- [X] I have searched in the [issues](https://github.com/apache/incubator-kyuubi/issues?q=is%3Aissue) and found no similar issues.
### What would you like to be improved?
Currently, Kyuubi uses `java.util.UUID#randomUUID()` to generate UUID, collision is more likely than UUID v1.
```
/**
* Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
*
* The {@code UUID} is generated using a cryptographically strong pseudo
* random number generator.
*
* @return A randomly generated {@code UUID}
*/
public static UUID randomUUID() {
SecureRandom ng = Holder.numberGenerator;
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new UUID(randomBytes);
}
```
Ref: https://www.sohamkamani.com/uuid-versions-explained/
### How should we improve?
Switch to UUID v1 algorithm.
A UUID v1 implementation under Apache License
https://github.com/datastax/java-driver/blob/4.14.1/core/src/main/java/com/datastax/oss/driver/api/core/uuid/Uuids.java
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Contributor guide
Research direction
The issue names java.util.UUID#randomUUID() as the current entry point and references Uuids.java from the DataStax Java driver as a UUID v1 implementation. Locate Kyuubi's UUID generation call sites and any related tests, then determine the required compatibility and collision behavior before replacing the algorithm. Done means UUID generation uses the agreed v1 approach and the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100