Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

slfan1989
Copy link
Contributor

Problem

In JdbcLockFactory#initializeLockTables(), the ResultSet returned by DatabaseMetaData#getTables(...) is not closed explicitly. This can lead to resource leaks (open cursors/handles) on certain JDBC drivers and databases.

Changes

  • Wrapped the ResultSet in a try-with-resources block to ensure it is always closed.
  • Minor code formatting adjustments for readability.

@github-actions github-actions bot added the flink label Aug 15, 2025
@slfan1989
Copy link
Contributor Author

@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 ResultSet object.

Copy link
Contributor

@Guosmilesmile Guosmilesmile left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: newline

Copy link
Contributor Author

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.

@pvary
Copy link
Contributor

pvary commented Aug 15, 2025

@slfan1989: good catch! Thanks for reporting and fixing

@stevenzwu stevenzwu added this to the Iceberg 1.10.0 milestone Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants