HDDS-13860. RocksDatabase#open leaks column family handles when failing to read cfOptions from file#9225
Merged
smengcl merged 1 commit intoapache:masterfrom Oct 31, 2025
Merged
Conversation
…ng to read cfOptions from file
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a resource leak by properly closing TableConfig objects created for extra column families discovered in the database. The change ensures that column family options allocated for extra tables (those not in the provided families set) are properly released in both success and error paths.
- Extracted
extravariable declaration outside the try block to enable cleanup in the finally block - Added a finally block to close extra TableConfig objects after database opening
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sadanand48
approved these changes
Oct 31, 2025
Contributor
sadanand48
left a comment
There was a problem hiding this comment.
Thanks @smengcl for the patch, LGTM
Contributor
Author
|
Thanks @sadanand48 for reviewing this. |
jojochuang
reviewed
Nov 1, 2025
Contributor
There was a problem hiding this comment.
Probably a bug from HDDS-6323 but it is used only by a test so it's okay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
(Found this during SnapshotDefragService development, but this bug is not in SDS.)
In RocksDatabase#open, when it fails to read column family options from file, it will fall back to getting the default column family options:
ozone/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TableConfig.java
Lines 58 to 60 in f30870f
Corresponding error messages when failing to read cfOptions from file:
But those options aren't properly released later, leading to leaks, e.g. output:
Note: The following is a snippet that can be used to trigger the leak before the fix:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13860
How was this patch tested?