From a9c8d4ef15ed22196260ecf6326a5d3b5a5cbbe8 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Mon, 11 Dec 2017 18:14:12 -0800 Subject: [PATCH] Fix memory issue introduced by 2f1a3a4d748ea92c282a1302b1523adc6d67ce81 Summary: Closes https://github.com/facebook/rocksdb/pull/3256 Differential Revision: D6541714 Pulled By: siying fbshipit-source-id: 40efd89b68587a9d58cfe6f4eebd771c2d9f1542 --- table/block_based_table_reader.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/table/block_based_table_reader.cc b/table/block_based_table_reader.cc index 9dc21c383..11fbf7a65 100644 --- a/table/block_based_table_reader.cc +++ b/table/block_based_table_reader.cc @@ -410,12 +410,13 @@ class HashIndexReader : public IndexReader { return Status::OK(); } + Slice dummy_comp_dict; // Read contents for the blocks BlockContents prefixes_contents; BlockFetcher prefixes_block_fetcher( file, prefetch_buffer, footer, ReadOptions(), prefixes_handle, &prefixes_contents, ioptions, true /* decompress */, - Slice() /*compression dict*/, cache_options); + dummy_comp_dict /*compression dict*/, cache_options); s = prefixes_block_fetcher.ReadBlockContents(); if (!s.ok()) { return s; @@ -424,7 +425,7 @@ class HashIndexReader : public IndexReader { BlockFetcher prefixes_meta_block_fetcher( file, prefetch_buffer, footer, ReadOptions(), prefixes_meta_handle, &prefixes_meta_contents, ioptions, true /* decompress */, - Slice() /*compression dict*/, cache_options); + dummy_comp_dict /*compression dict*/, cache_options); prefixes_meta_block_fetcher.ReadBlockContents(); if (!s.ok()) { // TODO: log error @@ -1143,10 +1144,12 @@ FilterBlockReader* BlockBasedTable::ReadFilter( } BlockContents block; - BlockFetcher block_fetcher( - rep->file.get(), prefetch_buffer, rep->footer, ReadOptions(), - filter_handle, &block, rep->ioptions, false /* decompress */, - Slice() /*compression dict*/, rep->persistent_cache_options); + Slice dummy_comp_dict; + + BlockFetcher block_fetcher(rep->file.get(), prefetch_buffer, rep->footer, + ReadOptions(), filter_handle, &block, + rep->ioptions, false /* decompress */, + dummy_comp_dict, rep->persistent_cache_options); Status s = block_fetcher.ReadBlockContents(); if (!s.ok()) { @@ -1913,10 +1916,11 @@ Status BlockBasedTable::VerifyChecksumInBlocks(InternalIterator* index_iter) { break; } BlockContents contents; + Slice dummy_comp_dict; BlockFetcher block_fetcher(rep_->file.get(), nullptr /* prefetch buffer */, rep_->footer, ReadOptions(), handle, &contents, rep_->ioptions, false /* decompress */, - Slice() /*compression dict*/, + dummy_comp_dict /*compression dict*/, rep_->persistent_cache_options); s = block_fetcher.ReadBlockContents(); if (!s.ok()) { @@ -2203,10 +2207,12 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) { BlockHandle handle; if (FindMetaBlock(meta_iter.get(), filter_block_key, &handle).ok()) { BlockContents block; + Slice dummy_comp_dict; BlockFetcher block_fetcher( rep_->file.get(), nullptr /* prefetch_buffer */, rep_->footer, ReadOptions(), handle, &block, rep_->ioptions, false /*decompress*/, - Slice() /*compression dict*/, rep_->persistent_cache_options); + dummy_comp_dict /*compression dict*/, + rep_->persistent_cache_options); s = block_fetcher.ReadBlockContents(); if (!s.ok()) { rep_->filter.reset(new BlockBasedFilterBlockReader(