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

Fix race condition in IteratorWithLocalStatistics #5149

Closed
Closed
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
fix race condition on iter callback
  • Loading branch information
myabandeh committed Apr 3, 2019
commit def717d3b39ca417cd42056d05b43e0850bf7ad0
13 changes: 10 additions & 3 deletions db/db_iterator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,21 @@ class DBIteratorTest : public DBTestBase,
SequenceNumber seq = read_options.snapshot != nullptr
? read_options.snapshot->GetSequenceNumber()
: db_->GetLatestSequenceNumber();
read_callback_.SetSnapshot(seq);
bool use_read_callback = GetParam();
ReadCallback* read_callback = use_read_callback ? &read_callback_ : nullptr;
DummyReadCallback* read_callback = nullptr;
if (use_read_callback) {
read_callback = new DummyReadCallback();
read_callback->SetSnapshot(seq);
InstrumentedMutexLock lock(&mutex_);
read_callbacks_.push_back(
std::unique_ptr<DummyReadCallback>(read_callback));
}
return dbfull()->NewIteratorImpl(read_options, cfd, seq, read_callback);
}

private:
DummyReadCallback read_callback_;
InstrumentedMutex mutex_;
std::vector<std::unique_ptr<DummyReadCallback>> read_callbacks_;
};

class FlushBlockEveryKeyPolicy : public FlushBlockPolicy {
Expand Down