mirror of https://github.com/facebook/rocksdb.git
avoid updating index type during iterator creation (#5288)
Summary: Right now there is a potential race condition where two threads are created to iterate through the DB (https://gist.github.com/miasantreble/88f5798a397ee7cb8e7baff9db2d9e85). The problem is that in `BlockBasedTable::NewIndexIterator`, if both threads failed to find index_reader from block cache, they will call `CreateIndexReader->UpdateIndexType()` which creates a race to update `index_type` in the shared rep_ object. By checking the code, we realize the index type is always populated by `PrefetchIndexAndFilterBlocks` during the table `Open` call, so there is no need to update index type every time during iterator creation. This PR attempts to fix the race condition by removing the unnecessary call to `UpdateIndexType` Pull Request resolved: https://github.com/facebook/rocksdb/pull/5288 Differential Revision: D15252509 Pulled By: miasantreble fbshipit-source-id: 6e3258652121d5c76d267f7ac457e15c5e84756e
This commit is contained in:
parent
930bfa5750
commit
eea1cad850
|
@ -3178,7 +3178,7 @@ BlockBasedTableOptions::IndexType BlockBasedTable::UpdateIndexType() {
|
|||
Status BlockBasedTable::CreateIndexReader(
|
||||
FilePrefetchBuffer* prefetch_buffer, IndexReader** index_reader,
|
||||
InternalIterator* preloaded_meta_index_iter, int level) {
|
||||
auto index_type_on_file = UpdateIndexType();
|
||||
auto index_type_on_file = rep_->index_type;
|
||||
|
||||
auto file = rep_->file.get();
|
||||
const InternalKeyComparator* icomparator = &rep_->internal_comparator;
|
||||
|
|
Loading…
Reference in New Issue