Fix for when block.cache_handle is nullptr

Summary:
When using with compressed cache it is possible that the status is ok but the block is not actually added to the block cache. The patch takes this case into account.
Closes https://github.com/facebook/rocksdb/pull/2945

Differential Revision: D5937613

Pulled By: maysamyabandeh

fbshipit-source-id: 5428cf1115e5046b3d01ab78d26cb181122af4c6
This commit is contained in:
Maysam Yabandeh 2017-09-29 07:55:22 -07:00 committed by Facebook Github Bot
parent 5df172da2f
commit ab0542f5ec
1 changed files with 9 additions and 5 deletions

View File

@ -259,12 +259,16 @@ class PartitionIndexReader : public IndexReader, public Cleanable {
assert(s.ok() || block.value == nullptr);
if (s.ok() && block.value != nullptr) {
assert(block.cache_handle != nullptr);
if (pin) {
partition_map_[handle.offset()] = block;
RegisterCleanup(&ReleaseCachedEntry, block_cache, block.cache_handle);
if (block.cache_handle != nullptr) {
if (pin) {
partition_map_[handle.offset()] = block;
RegisterCleanup(&ReleaseCachedEntry, block_cache,
block.cache_handle);
} else {
block_cache->Release(block.cache_handle);
}
} else {
block_cache->Release(block.cache_handle);
delete block.value;
}
}
}