Skip to content

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

Merged
lidavidm merged 1 commit intoapache:mainfrom
fb64:jni-thread
Feb 20, 2024
Merged

GH-20379: [Java] Dataset Failed to update reservation while freeing bytes#40101
lidavidm merged 1 commit intoapache:mainfrom
fb64:jni-thread

Conversation

@fb64
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy link
Copy Markdown
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
Copy Markdown
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
@lidavidm lidavidm removed the awaiting merge Awaiting merge label Feb 20, 2024
@conbench-apache-arrow
Copy link
Copy Markdown

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
Copy Markdown
Member

@github-actions crossbow submit java-jars

@github-actions
Copy link
Copy Markdown

Revision: 9a76007

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

Task Status
java-jars GitHub Actions

pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
…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 <florian.bernard@openairlines.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
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