-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Flink: Fix ResultSet resource leak in JdbcLockFactory.initializeLockTables(). #13821
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
Flink: Fix ResultSet resource leak in JdbcLockFactory.initializeLockTables(). #13821
Conversation
@pvary @Guosmilesmile @mxm This is a relatively minor change, but I believe it is still necessary, as the current implementation does not release resources after using the |
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.
LGTM
try (PreparedStatement ps = conn.prepareStatement(CREATE_LOCK_TABLE_SQL)) { | ||
ps.execute(); | ||
} | ||
return true; |
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.
Nit: newline
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.
Thank you for helping review the code! I have already fixed this issue.
@slfan1989: good catch! Thanks for reporting and fixing |
@pvary @stevenzwu Thank you very much for reviewing this PR. I’ve re-triggered the build, and the results now look as expected. Could you please help review this PR again? |
thanks @slfan1989 for the fix and everyone for the review |
Thank you all for your reviews and feedback on this PR! |
Problem
In
JdbcLockFactory#initializeLockTables()
, theResultSet
returned byDatabaseMetaData#getTables(...)
is not closed explicitly. This can lead to resource leaks (open cursors/handles) on certain JDBC drivers and databases.Changes
ResultSet
in a try-with-resources block to ensure it is always closed.