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

fix: check if handle has been initialized before closing #1554

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

wForget
Copy link
Member

@wForget wForget commented Mar 19, 2025

Which issue does this PR close?

Part of #1553

Rationale for this change

Check that the handle is initialized before closing to avoid native thread panic.

What changes are included in this PR?

How are these changes tested?

before this:
image

after this:
image

@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 58.38%. Comparing base (f09f8af) to head (0a646fa).
Report is 95 commits behind head on main.

Files with missing lines Patch % Lines
...va/org/apache/comet/parquet/NativeBatchReader.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1554      +/-   ##
============================================
+ Coverage     56.12%   58.38%   +2.25%     
- Complexity      976      985       +9     
============================================
  Files           119      122       +3     
  Lines         11743    12217     +474     
  Branches       2251     2280      +29     
============================================
+ Hits           6591     7133     +542     
+ Misses         4012     3951      -61     
+ Partials       1140     1133       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Native.closeRecordBatchReader(this.handle);
if (handle > 0) {
Native.closeRecordBatchReader(this.handle);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

And should we set handle to zero after being closed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that makes sense to me.

@parthchandra
Copy link
Contributor

Is it possible to add a unit test for this?

Comment on lines 462 to 463
if (handle > 0) {
Native.closeRecordBatchReader(this.handle);
Copy link
Member

Choose a reason for hiding this comment

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

nit: we refer to both handle and this.handle. I assume they are the same thing but it would be nice to make them consistent

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, changed

@wForget
Copy link
Member Author

wForget commented Mar 20, 2025

Is it possible to add a unit test for this?

Do we need to add a error test case for this obvious anomaly?

@parthchandra
Copy link
Contributor

Is it possible to add a unit test for this?

Do we need to add a error test case for this obvious anomaly?

It's not necessary. I just wanted to see in what condition the NativeBatchReader can be called after close has been called. Just in case there is a fundamental error that we are overlooking.

@wForget
Copy link
Member Author

wForget commented Mar 20, 2025

I just wanted to see in what condition the NativeBatchReader can be called after close has been called.

The scenario I encountered was not NativeBatchReader called after close, but an exception occurred during NativeBatchReader initialization and close was called. You can see some information in the first screenshot of description of #1553

@parthchandra
Copy link
Contributor

I just wanted to see in what condition the NativeBatchReader can be called after close has been called.

The scenario I encountered was not NativeBatchReader called after close, but an exception occurred during NativeBatchReader initialization and close was called. You can see some information in the first screenshot of description of #1553

Ah. Thanks for clarifying

@andygrove andygrove merged commit 5224108 into apache:main Mar 20, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants