Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-20379: [Java] Dataset Failed to update reservation while freeing bytes #40101

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

fb64
Copy link
Contributor

@fb64 fb64 commented Feb 16, 2024

Rationale for this change

Better controls JNI Thread management in java dataset module to fix #20379
Re-use the same code found in the java arrow-c-data module : https://github.com/apache/arrow/blob/main/java/c/src/main/cpp/jni_wrapper.cc#L107

May JNIEnvGuard class code can be put in a common place for both libraries ...

What changes are included in this PR?

N/A

Are these changes tested?

These changes has been tested with : https://gist.github.com/fb64/71880cde297bc5234b02b68b785670fd
on Linux X86_64 architecture

Are there any user-facing changes?

N/A

@fb64 fb64 requested a review from lidavidm as a code owner February 16, 2024 17:15
Copy link

⚠️ GitHub issue #20379 has been automatically assigned in GitHub to PR creator.

@@ -83,6 +83,40 @@ void ThrowIfError(const arrow::Status& status) {
}
}

class JNIEnvGuard {
public:
explicit JNIEnvGuard(JavaVM* vm) : vm_(vm), should_detach_(false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should initialize in the order the fields are declared, and env_ should be initialized. Probably better to re-order the fields such that the bool is the last field though to minimize padding.

Copy link
Contributor Author

@fb64 fb64 Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env_ is initialized at the end of the constructor...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler emits a build warning if it isn't done in the initializer list (even though you are setting it later).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok fixed, I didn't get (or I missed) the c++ compiler's warnings with archery ...

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Feb 16, 2024
return arrow::Status::Invalid("JNIEnv was not attached to current thread");
}
JNIEnvGuard guard(vm_);
JNIEnv* env = guard.env();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function wasn't throwing previously. It was returning an error status previously. Are the callers ready to handle exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch added to maintain the initial behavior

@fb64 fb64 force-pushed the jni-thread branch 2 times, most recently from a5486c5 to c2132ce Compare February 16, 2024 23:20
…eing bytes: JNIEnv was not attached to current thread
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Feb 19, 2024
@lidavidm lidavidm merged commit df9e0c1 into apache:main Feb 20, 2024
16 checks passed
@lidavidm lidavidm removed the awaiting merge Awaiting merge label Feb 20, 2024
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit df9e0c1.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.

@fb64 fb64 deleted the jni-thread branch February 21, 2024 20:58
@lidavidm
Copy link
Member

@github-actions crossbow submit java-jars

Copy link

Revision: 9a76007

Submitted crossbow builds: ursacomputing/crossbow @ actions-09542ccf6f

Task Status
java-jars GitHub Actions

zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Feb 28, 2024
…eing bytes (apache#40101)

### Rationale for this change
Better controls JNI Thread management in java dataset module to fix apache#20379 
Re-use the same code found in the java arrow-c-data module : https://github.com/apache/arrow/blob/main/java/c/src/main/cpp/jni_wrapper.cc#L107

May JNIEnvGuard class code can be put in a common place for both libraries ...

### What changes are included in this PR?
N/A

### Are these changes tested?
These changes has been tested with :  https://gist.github.com/fb64/71880cde297bc5234b02b68b785670fd 
on Linux X86_64 architecture

### Are there any user-facing changes?
N/A

* Closes: apache#20379

Authored-by: Florian Bernard <[email protected]>
Signed-off-by: David Li <[email protected]>
thisisnic pushed a commit to thisisnic/arrow that referenced this pull request Mar 8, 2024
…eing bytes (apache#40101)

### Rationale for this change
Better controls JNI Thread management in java dataset module to fix apache#20379 
Re-use the same code found in the java arrow-c-data module : https://github.com/apache/arrow/blob/main/java/c/src/main/cpp/jni_wrapper.cc#L107

May JNIEnvGuard class code can be put in a common place for both libraries ...

### What changes are included in this PR?
N/A

### Are these changes tested?
These changes has been tested with :  https://gist.github.com/fb64/71880cde297bc5234b02b68b785670fd 
on Linux X86_64 architecture

### Are there any user-facing changes?
N/A

* Closes: apache#20379

Authored-by: Florian Bernard <[email protected]>
Signed-off-by: David Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Java] Dataset Failed to update reservation while freeing bytes: JNIEnv was not attached to current thread
4 participants