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
main
Maysam Yabandeh 7 years ago committed by Facebook Github Bot
parent 5df172da2f
commit ab0542f5ec
  1. 14
      table/block_based_table_reader.cc

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

Loading…
Cancel
Save