fix: JNI local reference cleanup in JVMClasses::with_env#4225
Merged
mbutrovich merged 2 commits intoapache:mainfrom May 5, 2026
Merged
fix: JNI local reference cleanup in JVMClasses::with_env#4225mbutrovich merged 2 commits intoapache:mainfrom
mbutrovich merged 2 commits intoapache:mainfrom
Conversation
Contributor
|
Thanks @0lai0! Starting CI and will review today. |
mbutrovich
approved these changes
May 5, 2026
Contributor
mbutrovich
left a comment
There was a problem hiding this comment.
Looks right to me, thanks for the quick fix @0lai0! Approved pending CI.
Contributor
Author
|
Thanks @mbutrovich for reviews. : ) |
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.
Which issue does this PR close?
Closes #4172
Rationale for this change
JVMClasses::with_envattaches native worker threads to the JVM and then runs JNI call-site closures directly. Executor worker threads can stay attached for the JVM lifetime, so JNI local references created inside those closures may accumulate instead of being released at each call boundary.Wrapping each
with_envclosure in a JNI local frame gives all existing call sites a consistent push/pop boundary and prevents long-running executor threads from retaining local references across batches.What changes are included in this PR?
JVMClasses::with_envclosures withEnv::with_local_frame.E: From<CometError>caller contract by adapting local-frame JNI errors internally.with_env.How are these changes tested?
cargo fmt -p datafusion-comet-jni-bridgecargo check -p datafusion-comet-jni-bridgecargo test -p datafusion-comet-jni-bridgecargo check -p datafusion-comet --all-targetscargo clippy -p datafusion-comet-jni-bridge --all-targets -- -D warningscargo clippy -p datafusion-comet --lib -- -D warningsJAVA_TOOL_OPTIONS="-Xcheck:jni" ./mvnw test -Dtest=none -Dsuites="org.apache.comet.exec.CometNativeShuffleSuite" -Pspark-3.5