Browse Source

KAFKA-8323: Close RocksDBStore's BloomFilter (#6672)

Any RocksJava object that inherits from org.rocksdb.AbstractNativeReference must be closed explicitly in order to free up the memory of the backing C++ object. The BloomFilter extends RocksObject (which implements AbstractNativeReference) and should be also be closed in RocksDBStore#close to avoid leaking memory.

Reviewers: Bill Bejeck <bbejeck@gmail.com>
pull/6676/head
A. Sophie Blee-Goldman 6 years ago committed by Bill Bejeck
parent
commit
a1b1e088b9
  1. 6
      streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java

6
streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java

@ -90,6 +90,7 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt @@ -90,6 +90,7 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt
private RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter userSpecifiedOptions;
WriteOptions wOptions;
FlushOptions fOptions;
private BloomFilter filter;
private volatile boolean prepareForBulkload = false;
ProcessorContext internalProcessorContext;
@ -120,7 +121,9 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt @@ -120,7 +121,9 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt
final BlockBasedTableConfig tableConfig = new BlockBasedTableConfig();
tableConfig.setBlockCacheSize(BLOCK_CACHE_SIZE);
tableConfig.setBlockSize(BLOCK_SIZE);
tableConfig.setFilter(new BloomFilter());
filter = new BloomFilter();
tableConfig.setFilter(filter);
userSpecifiedOptions.optimizeFiltersForHits();
userSpecifiedOptions.setTableFormatConfig(tableConfig);
@ -392,6 +395,7 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt @@ -392,6 +395,7 @@ public class RocksDBStore implements KeyValueStore<Bytes, byte[]>, BulkLoadingSt
wOptions.close();
fOptions.close();
db.close();
filter.close();
dbAccessor = null;
userSpecifiedOptions = null;

Loading…
Cancel
Save