Release RocksDB's default ReadOptions on store close - #23085
Open
alanlau28 wants to merge 1 commit into
Open
Conversation
rocksdbjni allocates a ReadOptions per RocksDB instance and never closes it, so every store and segment Streams opens leaks native memory for the lifetime of the JVM. Release it after db.close() at both close sites, including openDB's error-cleanup path.
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.
org.rocksdb.RocksDBallocates aReadOptionsin a field initializer and never closes it:private final ReadOptions defaultReadOptions_ = new ReadOptions(); // RocksDB.java:42Streams is unusually exposed: it opens one RocksDB per store and per segment, and
AbstractSegments.cleanupExpiredSegments()closes expired segments during ordinary processing, so windowed and session stores churn segments continuously. The loss accumulates in steady state, not just at rebalances.The change
RocksDBStorereleases the field immediately afterdb.close(), at both close sites —close()andcloseDbAndAccessors()(theopenDBerror-cleanup path, which leaks identically when an open fails partway). 40 lines of production code. No public API, configuration, metric or wire-protocol change.