tests/concurrency/isolation_level_test.cpp
// Look at the SSI paper (http://drkp.net/papers/ssi-vldb12.pdf).
// This is an anomaly involving three transactions (one of them is a readonly
// transaction).
Look at the SSI paper .
This is an anomaly involving three transactions (one of them is a readonly
transaction).
Look at the SSI paper . This is an anomaly involving three transactions ( one of them is a readonly transaction ) .
void SIAnomalyTest1() {
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  std::unique_ptr<storage::DataTable> table(
      TransactionTestsUtil::CreateTable());
  int current_batch_key = 10000;
  {
    TransactionScheduler scheduler(1, table.get(), &txn_manager);
    scheduler.Txn(0).Insert(current_batch_key, 100);
    scheduler.Txn(0).Update(100, 1);
    scheduler.Txn(0).Commit();
    scheduler.Run();
    EXPECT_EQ(RESULT_SUCCESS, scheduler.schedules[0].txn_result);
  }
  {
    if (concurrency::TransactionManagerFactory::GetProtocol() == CONCURRENCY_TYPE_EAGER_WRITE) {
      LOG_INFO("Bypass eager write");
      return;
    }
    TransactionScheduler scheduler(4, table.get(), &txn_manager);
    scheduler.Txn(1).ReadStore(current_batch_key, 0);
    scheduler.Txn(2).Update(current_batch_key, 100 + 1);
    scheduler.Txn(2).Commit();
    scheduler.Txn(0).ReadStore(current_batch_key, -1);
    scheduler.Txn(0).Read(TXN_STORED_VALUE);
    scheduler.Txn(1).Update(TXN_STORED_VALUE, 2);
    scheduler.Txn(1).Commit();
    scheduler.Txn(0).Commit();
    scheduler.Txn(3).ReadStore(current_batch_key, -1);
    scheduler.Txn(3).Read(TXN_STORED_VALUE);
    scheduler.Txn(3).Commit();
    scheduler.Run();
    if (RESULT_SUCCESS == scheduler.schedules[0].txn_result &&
        RESULT_SUCCESS == scheduler.schedules[1].txn_result &&
        RESULT_SUCCESS == scheduler.schedules[2].txn_result) {
      EXPECT_TRUE(scheduler.schedules[0].results[1] ==
                  scheduler.schedules[3].results[1]);
    }
  }
}
void SIAnomalyTest1 ( ) { auto & txn_manager = concurrency :: TransactionManagerFactory :: GetInstance ( ) ; std :: unique_ptr < storage :: DataTable > table ( TransactionTestsUtil :: CreateTable ( ) ) ; int current_batch_key = 10000 ; { TransactionScheduler scheduler ( 1 , table . get ( ) , & txn_manager ) ; scheduler . Txn ( 0 ) . Insert ( current_batch_key , 100 ) ; scheduler . Txn ( 0 ) . Update ( 100 , 1 ) ; scheduler . Txn ( 0 ) . Commit ( ) ; scheduler . Run ( ) ; EXPECT_EQ ( RESULT_SUCCESS , scheduler . schedules [ 0 ] . txn_result ) ; } { if ( concurrency :: TransactionManagerFactory :: GetProtocol ( ) == CONCURRENCY_TYPE_EAGER_WRITE ) { LOG_INFO ( " " ) ; return ; } TransactionScheduler scheduler ( 4 , table . get ( ) , & txn_manager ) ; scheduler . Txn ( 1 ) . ReadStore ( current_batch_key , 0 ) ; scheduler . Txn ( 2 ) . Update ( current_batch_key , 100 + 1 ) ; scheduler . Txn ( 2 ) . Commit ( ) ; scheduler . Txn ( 0 ) . ReadStore ( current_batch_key , -1 ) ; scheduler . Txn ( 0 ) . Read ( TXN_STORED_VALUE ) ; scheduler . Txn ( 1 ) . Update ( TXN_STORED_VALUE , 2 ) ; scheduler . Txn ( 1 ) . Commit ( ) ; scheduler . Txn ( 0 ) . Commit ( ) ; scheduler . Txn ( 3 ) . ReadStore ( current_batch_key , -1 ) ; scheduler . Txn ( 3 ) . Read ( TXN_STORED_VALUE ) ; scheduler . Txn ( 3 ) . Commit ( ) ; scheduler . Run ( ) ; if ( RESULT_SUCCESS == scheduler . schedules [ 0 ] . txn_result && RESULT_SUCCESS == scheduler . schedules [ 1 ] . txn_result && RESULT_SUCCESS == scheduler . schedules [ 2 ] . txn_result ) { EXPECT_TRUE ( scheduler . schedules [ 0 ] . results [ 1 ] == scheduler . schedules [ 3 ] . results [ 1 ] ) ; } } }
Look at the SSI paper (http://drkp.net/papers/ssi-vldb12.pdf).
Look at the SSI paper ( http : // drkp . net / papers / ssi - vldb12 . pdf ) .
// Prepare // Bypass eager write // Test against anomaly