-
Notifications
You must be signed in to change notification settings - Fork 915
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
Clean up buffers in case AssertionError #13262
Conversation
Calling The problem is with sub classes like
|
You want to treat this case differently since it is a special error on construction. In the viewHandle constructor case, the code you have seems fine but I would also 0 it out for good measure. In the OffHeapState constructor case, the state of concern is I would put comments on both constructors that this is now happening to make it extra clear and we don't forget this in the future. |
@abellina do you have anything else to add? I think I have addressed all your concerns |
columnVectors[i] = new ColumnVector(nativeHandles[i]); | ||
} | ||
} catch (Throwable t) { | ||
for (ColumnView columnView: columnVectors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit, since we know we are creating column vectors, I don't see the point of using the superclass here.
columnVectors[i] = new ColumnVector(nativeHandles[i]); | ||
} | ||
} catch (Throwable t) { | ||
for (ColumnView columnView: columnVectors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to closing the column vectors/views in the array, we also have pending nativeHandles
, sorry I just caught this one. In order to make it safer, we should also need to close the handles which are leaked. Should probably create a helper handles -> vectors, or handles -> views, if we don't have those already, since all the other places you changed are similar.
I would change the loop like so:
try {
for (int i = 0; i < nativeHandles.length; i++) {
columnVectors[i] = new ColumnVector(nativeHandles[i]);
nativeHandles[i] = 0; // mark the handle as consumed
}
} catch (Throwable t) {
for (ColumnVector cv : columnVectors) {
if (cv != null) {
cv.close();
}
}
for (long handle : nativeHandles) {
if (handle != 0) {
ColumnVector.deleteCudfColumn(handle);
}
}
throw t;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! But why not close all the nativeHandles
? We got them as a result of slice
They should all be cleaned out since we have encountered an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the same thing should happen in splitAsViews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but since you have handed some handles to the vector/view, the expectation is that the vector/view will close the handle they were given. So you don't want to double delete these.
@abellina thank you for taking a look and catching things that I had missed. I have covered the missed cases I think. I have also created a helper method in ColumnView and also replaced places where it should be called instead of the code we were using before. Please take a look again when you have a chance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had one typo change request, otherwise LGTM
Co-authored-by: Alessandro Bellina <[email protected]>
/merge |
In case
ColumnView
throws anAssertionError
which it can after #13071, we should close out the open buffers.fixes #13225
Description
Checklist