[KYUUBI #7668][SPARK] Use UUIDv7 for executor podNamePrefix to avoid same-millisecond collision - #7669
Closed
littlexyw wants to merge 1 commit into
Closed
Conversation
pan3793
approved these changes
Aug 28, 2026
pan3793
left a comment
Member
There was a problem hiding this comment.
LGTM. But please fill PR description seriously.
…avoid same-millisecond collision SparkSQLEngine.generateExecutorPodNamePrefixForK8s built the podNamePrefix as `kyuubi-<user>-<epoch-millis>`. Two engines for the same user launched within the same millisecond in the same namespace ended up with an identical `spark.kubernetes.executor.podNamePrefix`, causing their executor pods (`<prefix>-exec-<id>`) to collide inside the namespace and one of the two apps to fail creating executors. Replace the epoch-millis suffix with a UUIDv7 from the existing `UuidUtils.generateUUIDv7` helper. UUIDv7 keeps the 48-bit epoch millis in its leading bits so pod names remain roughly time-ordered when listed by name, while the trailing 74 bits of secure randomness make same-millisecond collisions essentially impossible. The oversized-user-name fallback path is switched to the same UUIDv7 for consistency. Add a concurrent unit test that fans out 1000 prefix generations across 10 threads for the same user and asserts every generated prefix is unique.
littlexyw
force-pushed
the
kyuubi-7668-executor-podname-uuidv7
branch
from
August 31, 2026 02:29
eb16a9f to
b29ebc7
Compare
pan3793
pushed a commit
that referenced
this pull request
Aug 31, 2026
…same-millisecond collision ### Why are the changes needed? On Kubernetes, `SparkSQLEngine.generateExecutorPodNamePrefixForK8s` built the executor podNamePrefix as `kyuubi-<user>-<epoch-millis>`. When two engines for the same user (same `resolvedUserName`) are launched within the same millisecond in the same namespace — e.g. a burst of short-lived engines from the same user, or two Kyuubi servers racing to launch engines for a `USER` share level — the two engines get an identical `spark.kubernetes.executor.podNamePrefix`. Their executor pod names (`<prefix>-exec-<id>`) then collide inside the namespace, and one of the two apps fails to create executors until the other releases the names. This PR replaces the epoch-millis suffix with a UUIDv7 from the existing `UuidUtils.generateUUIDv7` helper. UUIDv7 keeps the 48-bit epoch millis in its leading bits so pod names remain roughly time-ordered when listed by name, while the trailing 74 bits of secure randomness make same-millisecond collisions essentially impossible. The oversized-user-name fallback path is switched to the same UUIDv7 for consistency. ### How was this patch tested? - Added a concurrent unit test `generate executor pod name prefix should be unique for concurrent calls with the same user` in `SparkSQLEngineSuite` that fans out 1000 prefix generations across 10 threads for the same user and asserts every generated prefix is unique. Under the pre-fix epoch-millis implementation this test necessarily fails, since many calls land on the same millisecond and produce identical prefixes. - The existing `[KYUUBI #3385] generate executor pod name prefix with user or UUID` test still passes (sanitization, length cap, and pod-log-directory length invariants unchanged). ### Was this patch assisted by generative AI tooling? Assisted-by: Claude Opus 4.7 Closes #7669 from littlexyw/kyuubi-7668-executor-podname-uuidv7. Closes #7668 b29ebc7 [littlexyw] [KYUUBI #7668][SPARK] Use UUIDv7 for executor podNamePrefix to avoid same-millisecond collision Authored-by: littlexyw <shea_wong@163.com> Signed-off-by: Cheng Pan <chengpan@apache.org> (cherry picked from commit f35e7df) Signed-off-by: Cheng Pan <chengpan@apache.org>
Member
|
thanks, merged to master/1.12 |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
On Kubernetes,
SparkSQLEngine.generateExecutorPodNamePrefixForK8sbuilt the executor podNamePrefix askyuubi-<user>-<epoch-millis>. When two engines for the same user (sameresolvedUserName) are launched within the same millisecond in the same namespace — e.g. a burst of short-lived engines from the same user, or two Kyuubi servers racing to launch engines for aUSERshare level — the two engines get an identicalspark.kubernetes.executor.podNamePrefix. Their executor pod names (<prefix>-exec-<id>) then collide inside the namespace, and one of the two apps fails to create executors until the other releases the names.This PR replaces the epoch-millis suffix with a UUIDv7 from the existing
UuidUtils.generateUUIDv7helper. UUIDv7 keeps the 48-bit epoch millis in its leading bits so pod names remain roughly time-ordered when listed by name, while the trailing 74 bits of secure randomness make same-millisecond collisions essentially impossible. The oversized-user-name fallback path is switched to the same UUIDv7 for consistency.How was this patch tested?
generate executor pod name prefix should be unique for concurrent calls with the same userinSparkSQLEngineSuitethat fans out 1000 prefix generations across 10 threads for the same user and asserts every generated prefix is unique. Under the pre-fix epoch-millis implementation this test necessarily fails, since many calls land on the same millisecond and produce identical prefixes.[KYUUBI #3385] generate executor pod name prefix with user or UUIDtest still passes (sanitization, length cap, and pod-log-directory length invariants unchanged).Was this patch assisted by generative AI tooling?
Assisted-by: Claude Opus 4.7