-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Core: Add finalizer to ResolvingFileIO #7536
Conversation
@@ -83,21 +90,22 @@ public Map<String, String> properties() { | |||
|
|||
@Override | |||
public void initialize(Map<String, String> newProperties) { | |||
close(); // close and discard any existing FileIO instances |
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.
@rdblue do you remember why this was necessary? I added a flag for detecting whether close()
was already called to be used in the finalize()
method. Given that close()
is being called here and then later again during a proper close()
call, I ended up removing this call here
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.
It was just in case initialize
was called again. Technically, that invalidates the configuration and we should close/reopen any FileIO instances that are held.
We could just reset isClosed
in this method instead of removing this.
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've reset isClosed
here for now but I think we should consider removing this close()
call from initialize(..)
in a follow-up
|
||
@SuppressWarnings("checkstyle:NoFinalizer") | ||
@Override | ||
protected void finalize() throws Throwable { |
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.
Sorry @nastra, but stong -100 on using finalize()
at all. See JDK-8165641.
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.
@snazy, we know.
Iceberg uses this pattern to ensure that close is called. We also log the stack trace at WARN so that we can track down leaks. It is better to close in a finalizer than to not close at all.
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.
@snazy I agree that finalize()
is a pattern we shouldn't rely on, but on Spark executor notes we don't have any other way of closing resources unfortunately
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.
Object.finalize()
should really never be overwritten - it causes security and system stability issues.
a2a6682
to
f54428a
Compare
No description provided.