Example #1
0
TEST_F(LoggingTests, BasicLogManagerTest) {
  peloton_logging_mode = LOGGING_TYPE_INVALID;
  auto &log_manager = logging::LogManager::GetInstance();
  log_manager.DropFrontendLoggers();
  log_manager.SetLoggingStatus(LOGGING_STATUS_TYPE_INVALID);
  // just start, write a few records and exit
  catalog::Schema *table_schema = new catalog::Schema(
      {ExecutorTestsUtil::GetColumnInfo(0), ExecutorTestsUtil::GetColumnInfo(1),
       ExecutorTestsUtil::GetColumnInfo(2),
       ExecutorTestsUtil::GetColumnInfo(3)});
  std::string table_name("TEST_TABLE");

  // Create table.
  bool own_schema = true;
  bool adapt_table = false;
  storage::DataTable *table = storage::TableFactory::GetDataTable(
      12345, 123456, table_schema, table_name, 1, own_schema, adapt_table);

  storage::Database test_db(12345);
  test_db.AddTable(table);
  catalog::Manager::GetInstance().AddDatabase(&test_db);
  concurrency::TransactionManager &txn_manager =
      concurrency::TransactionManagerFactory::GetInstance();
  txn_manager.BeginTransaction();
  ExecutorTestsUtil::PopulateTable(table, 5, true, false, false);
  txn_manager.CommitTransaction();
  peloton_logging_mode = LOGGING_TYPE_NVM_WAL;

  log_manager.SetSyncCommit(true);
  EXPECT_FALSE(log_manager.ContainsFrontendLogger());
  log_manager.StartStandbyMode();
  log_manager.GetFrontendLogger(0)->SetTestMode(true);
  log_manager.StartRecoveryMode();
  log_manager.WaitForModeTransition(LOGGING_STATUS_TYPE_LOGGING, true);
  EXPECT_TRUE(log_manager.ContainsFrontendLogger());
  log_manager.SetGlobalMaxFlushedCommitId(4);
  concurrency::Transaction test_txn;
  cid_t commit_id = 5;
  log_manager.PrepareLogging();
  log_manager.LogBeginTransaction(commit_id);
  ItemPointer insert_loc(table->GetTileGroup(1)->GetTileGroupId(), 0);
  ItemPointer delete_loc(table->GetTileGroup(2)->GetTileGroupId(), 0);
  ItemPointer update_old(table->GetTileGroup(3)->GetTileGroupId(), 0);
  ItemPointer update_new(table->GetTileGroup(4)->GetTileGroupId(), 0);
  log_manager.LogInsert(commit_id, insert_loc);
  log_manager.LogUpdate(commit_id, update_old, update_new);
  log_manager.LogInsert(commit_id, delete_loc);
  log_manager.LogCommitTransaction(commit_id);

  // TODO: Check the flushed commit id
  // since we are doing sync commit we should have reached 5 already
  //EXPECT_EQ(commit_id, log_manager.GetPersistentFlushedCommitId());
  log_manager.EndLogging();
}
Example #2
0
int Csysarg_wish_wall::add(uint32_t userid, char* nick)
{
	uint32_t count = 0;	
	get_rd_count(&count);
	if(count < 900){
		insert(userid, nick);
	}
	else{
		int ret = update_old(userid);
		if(ret == USER_ID_NOFIND_ERR){
			ret = update_other(userid, nick);
		}
	}
	return 0;
}