Fix DBWriteTest::ReturnSequenceNumberMultiThreaded data race

Summary:
rocksdb::Random is not thread-safe. Have one Random for each thread instead.
Closes https://github.com/facebook/rocksdb/pull/2400

Differential Revision: D5173919

Pulled By: yiwu-arbug

fbshipit-source-id: 1a99c7b877f3893eb22355af49e321bcad4e53e6
main
Yi Wu 8 years ago committed by Facebook Github Bot
parent 215076ef06
commit f68d88be51
  1. 2
      db/db_write_test.cc

@ -39,7 +39,6 @@ TEST_P(DBWriteTest, ReturnSeuqneceNumber) {
TEST_P(DBWriteTest, ReturnSeuqneceNumberMultiThreaded) {
constexpr size_t kThreads = 16;
constexpr size_t kNumKeys = 1000;
Random rnd(4422);
Open();
ASSERT_EQ(0, dbfull()->GetLatestSequenceNumber());
// Check each sequence is used once and only once.
@ -48,6 +47,7 @@ TEST_P(DBWriteTest, ReturnSeuqneceNumberMultiThreaded) {
flags[i].clear();
}
auto writer = [&](size_t id) {
Random rnd(4422 + id);
for (size_t k = 0; k < kNumKeys; k++) {
WriteBatch batch;
batch.Put("key" + ToString(id) + "-" + ToString(k),

Loading…
Cancel
Save