Skip to content

Release RocksDB's default ReadOptions on store close - #23085

Open
alanlau28 wants to merge 1 commit into
apache:trunkfrom
alanlau28:rocksdb-readoptions-native-leak
Open

Release RocksDB's default ReadOptions on store close#23085
alanlau28 wants to merge 1 commit into
apache:trunkfrom
alanlau28:rocksdb-readoptions-native-leak

Conversation

@alanlau28

Copy link
Copy Markdown
Contributor

org.rocksdb.RocksDB allocates a ReadOptions in a field initializer and never closes it:

private final ReadOptions defaultReadOptions_ = new ReadOptions(); // RocksDB.java:42

Streams 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

RocksDBStore releases the field immediately after db.close(), at both close sites — close() and closeDbAndAccessors() (the openDB error-cleanup path, which leaks identically when an open fails partway). 40 lines of production code. No public API, configuration, metric or wire-protocol change.

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.
@github-actions github-actions Bot added triage PRs from the community streams labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

streams triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant