Skip to content

Commit

Permalink
single insert + fmt
Browse files Browse the repository at this point in the history
Signed-off-by: AveryQi115 <[email protected]>
  • Loading branch information
AveryQi115 committed Apr 5, 2024
1 parent 85bbebf commit eb4807a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/txn/txn_abort_serializable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ TEST(TxnBonusTest, DISABLED_SerializableTest) { // NOLINT
TEST(TxnBonusTest, DISABLE_ConcurrentSerializableTest) { // NOLINT
fmt::println(stderr, "--- SerializableTest2: Concurrent Serializable ---");
{
for(int i=0;i<10;i++){
for (int i = 0; i < 10; i++) {
auto bustub = std::make_unique<BustubInstance>();
EnsureIndexScan(*bustub);
Execute(*bustub, "CREATE TABLE maintable(a int, b int primary key)");
auto table_info = bustub->catalog_->GetTable("maintable");
auto txn1 = BeginTxnSerializable(*bustub, "txn1");
for(int i=0;i<1000;i++){
auto str_value = std::to_string(i+1000);
WithTxn(txn1, ExecuteTxn(*bustub, _var, _txn, "INSERT INTO maintable VALUES (1, " + str_value + ")"));
auto str_value2 = std::to_string(i+2000);
WithTxn(txn1, ExecuteTxn(*bustub, _var, _txn, "INSERT INTO maintable VALUES (0, " + str_value2 + ")"));
std::string query = "INSERT INTO maintable VALUES ";
for (int i = 0; i < 1000; i++) {
auto str_value = std::to_string(i + 1000);
query += i == 0 ? "(1," + str_value + ")" : ", (1," + str_value + ")";
auto str_value2 = std::to_string(i + 2000);
query += ", (0, " + str_value2 + ")";
}
WithTxn(txn1, ExecuteTxn(*bustub, _var, _txn, query));
WithTxn(txn1, CommitTxn(*bustub, _var, _txn));

auto txn2 = BeginTxnSerializable(*bustub, "txn2");
Expand All @@ -61,7 +63,7 @@ TEST(TxnBonusTest, DISABLE_ConcurrentSerializableTest) { // NOLINT
commit_threads.reserve(thread_cnt);
int success_cnt = 0;
std::mutex result_mutex;

commit_threads.emplace_back([txn2, &bustub, &result_mutex, &success_cnt]() {
auto res = bustub->txn_manager_->Commit(txn2);
{
Expand Down

0 comments on commit eb4807a

Please sign in to comment.