Skip to content
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

Ensure to release cache during KeyValueStorageRocksDB#close #2821

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class KeyValueStorageRocksDB implements KeyValueStorage {

private final WriteOptions optionSync;
private final WriteOptions optionDontSync;
private final Cache cache;

private final ReadOptions optionCache;
private final ReadOptions optionDontCache;
Expand Down Expand Up @@ -139,7 +140,7 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
options.setTargetFileSizeBase(sstSizeMB * 1024 * 1024);
options.setDeleteObsoleteFilesPeriodMicros(TimeUnit.HOURS.toMicros(1));

final Cache cache = new LRUCache(blockCacheSize);
this.cache = new LRUCache(blockCacheSize);
BlockBasedTableConfig tableOptions = new BlockBasedTableConfig();
tableOptions.setBlockSize(blockSize);
tableOptions.setBlockCache(cache);
Expand All @@ -154,6 +155,8 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
options.setLevelCompactionDynamicLevelBytes(true);

options.setTableFormatConfig(tableOptions);
} else {
this.cache = null;
}

// Configure file path
Expand Down Expand Up @@ -210,6 +213,9 @@ public KeyValueStorageRocksDB(String basePath, String subPath, DbConfigType dbCo
@Override
public void close() throws IOException {
db.close();
if (cache != null) {
cache.close();
}
optionSync.close();
optionDontSync.close();
optionCache.close();
Expand Down