mirror of https://github.com/facebook/rocksdb.git
Fix tsan compliant on AddPreparedBeforeMax (#5052)
Summary: Add a mutex to the test to synchronize before accessing the shared txn object. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5052 Differential Revision: D14386861 Pulled By: maysamyabandeh fbshipit-source-id: 5b32e209840b210c35af53848dc77f489a76c95a
This commit is contained in:
parent
79b6ab43ce
commit
04d3ac4e63
|
@ -2960,6 +2960,7 @@ TEST_P(WritePreparedTransactionTest, AddPreparedBeforeMax) {
|
|||
Transaction* txn = db->BeginTransaction(WriteOptions(), TransactionOptions());
|
||||
ASSERT_OK(txn->SetName("xid"));
|
||||
ASSERT_OK(txn->Put(Slice("key0"), uncommitted_value));
|
||||
port::Mutex txn_mutex_;
|
||||
|
||||
// t1) Insert prepared entry, t2) commit other entires to advance max
|
||||
// evicted sec and finish checking the existing prepared entires, t1)
|
||||
|
@ -2971,7 +2972,11 @@ TEST_P(WritePreparedTransactionTest, AddPreparedBeforeMax) {
|
|||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
rocksdb::port::Thread write_thread([&]() { ASSERT_OK(txn->Prepare()); });
|
||||
rocksdb::port::Thread write_thread([&]() {
|
||||
txn_mutex_.Lock();
|
||||
ASSERT_OK(txn->Prepare());
|
||||
txn_mutex_.Unlock();
|
||||
});
|
||||
|
||||
rocksdb::port::Thread read_thread([&]() {
|
||||
TEST_SYNC_POINT("AddPreparedBeforeMax::read_thread:start");
|
||||
|
@ -2987,7 +2992,9 @@ TEST_P(WritePreparedTransactionTest, AddPreparedBeforeMax) {
|
|||
auto snap = db->GetSnapshot();
|
||||
ASSERT_LT(wp_db->max_evicted_seq_, snap->GetSequenceNumber());
|
||||
// This is the scenario that we test for
|
||||
txn_mutex_.Lock();
|
||||
ASSERT_GT(wp_db->max_evicted_seq_, txn->GetId());
|
||||
txn_mutex_.Unlock();
|
||||
roptions.snapshot = snap;
|
||||
auto s = db->Get(roptions, db->DefaultColumnFamily(), "key0", &value);
|
||||
ASSERT_TRUE(s.IsNotFound());
|
||||
|
|
Loading…
Reference in New Issue