-
Notifications
You must be signed in to change notification settings - Fork 15.2k
KAFKA-3735: Dispose all RocksObejcts upon completeness #1411
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,17 +77,18 @@ public class RocksDBStore<K, V> implements KeyValueStore<K, V> { | |
| private final String name; | ||
| private final String parentDir; | ||
|
|
||
| private final Options options; | ||
| private final WriteOptions wOptions; | ||
| private final FlushOptions fOptions; | ||
|
|
||
| protected File dbDir; | ||
| private StateSerdes<K, V> serdes; | ||
| private final Serde<K> keySerde; | ||
| private final Serde<V> valueSerde; | ||
|
|
||
| private StateSerdes<K, V> serdes; | ||
| protected File dbDir; | ||
| private RocksDB db; | ||
|
|
||
| // the following option objects will be created at constructor and disposed at close() | ||
| private Options options; | ||
| private WriteOptions wOptions; | ||
| private FlushOptions fOptions; | ||
|
|
||
| private boolean loggingEnabled = false; | ||
| private int cacheSize = DEFAULT_UNENCODED_CACHE_SIZE; | ||
|
|
||
|
|
@@ -313,14 +314,16 @@ public void putAll(List<KeyValue<K, V>> entries) { | |
| private void putAllInternal(List<KeyValue<byte[], byte[]>> entries) { | ||
| WriteBatch batch = new WriteBatch(); | ||
|
|
||
| for (KeyValue<byte[], byte[]> entry : entries) { | ||
| batch.put(entry.key, entry.value); | ||
| } | ||
|
|
||
| try { | ||
| for (KeyValue<byte[], byte[]> entry : entries) { | ||
| batch.put(entry.key, entry.value); | ||
| } | ||
|
|
||
| db.write(wOptions, batch); | ||
| } catch (RocksDBException e) { | ||
| throw new ProcessorStateException("Error while batch writing to store " + this.name, e); | ||
| } finally { | ||
| batch.dispose(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -425,7 +428,15 @@ public void flushInternal() { | |
| @Override | ||
| public void close() { | ||
| flush(); | ||
| options.dispose(); | ||
| wOptions.dispose(); | ||
| fOptions.dispose(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want to null out these fields after you call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed you nulled out
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's not sufficient if one calls
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, will do. |
||
| db.close(); | ||
|
|
||
| options = null; | ||
| wOptions = null; | ||
| fOptions = null; | ||
| db = null; | ||
| } | ||
|
|
||
| private static class RocksDbIterator<K, V> implements KeyValueIterator<K, V> { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
We should tell users that they should call
close(as we did forKeyValueIterator).