Skip to content

Commit

Permalink
chore: more info for lock number incorrect (#569)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <iskyzh@gmail.com>
  • Loading branch information
skyzh authored Apr 27, 2023
1 parent 48422af commit e0163ed
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions test/concurrency/lock_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ void CheckAborted(Transaction *txn) { EXPECT_EQ(txn->GetState(), TransactionStat
void CheckCommitted(Transaction *txn) { EXPECT_EQ(txn->GetState(), TransactionState::COMMITTED); }

void CheckTxnRowLockSize(Transaction *txn, table_oid_t oid, size_t shared_size, size_t exclusive_size) {
EXPECT_EQ((*(txn->GetSharedRowLockSet()))[oid].size(), shared_size);
EXPECT_EQ((*(txn->GetExclusiveRowLockSet()))[oid].size(), exclusive_size);
bool correct = true;
correct = correct && (*txn->GetSharedRowLockSet())[oid].size() == shared_size;
correct = correct && (*txn->GetExclusiveRowLockSet())[oid].size() == exclusive_size;
if (!correct) {
fmt::print("row lock size incorrect for txn={} oid={}: expected (S={} X={}), actual (S={} X={})\n",
txn->GetTransactionId(), oid, shared_size, exclusive_size, (*txn->GetSharedRowLockSet())[oid].size(),
(*txn->GetExclusiveRowLockSet())[oid].size());
}
EXPECT_TRUE(correct);
}

int GetTxnTableLockSize(Transaction *txn, LockManager::LockMode lock_mode) {
Expand All @@ -52,11 +59,22 @@ int GetTxnTableLockSize(Transaction *txn, LockManager::LockMode lock_mode) {

void CheckTableLockSizes(Transaction *txn, size_t s_size, size_t x_size, size_t is_size, size_t ix_size,
size_t six_size) {
EXPECT_EQ(s_size, txn->GetSharedTableLockSet()->size());
EXPECT_EQ(x_size, txn->GetExclusiveTableLockSet()->size());
EXPECT_EQ(is_size, txn->GetIntentionSharedTableLockSet()->size());
EXPECT_EQ(ix_size, txn->GetIntentionExclusiveTableLockSet()->size());
EXPECT_EQ(six_size, txn->GetSharedIntentionExclusiveTableLockSet()->size());
bool correct = true;
correct = correct && s_size == txn->GetSharedTableLockSet()->size();
correct = correct && x_size == txn->GetExclusiveTableLockSet()->size();
correct = correct && is_size == txn->GetIntentionSharedTableLockSet()->size();
correct = correct && ix_size == txn->GetIntentionExclusiveTableLockSet()->size();
correct = correct && six_size == txn->GetSharedIntentionExclusiveTableLockSet()->size();
if (!correct) {
fmt::print(
"table lock size incorrect for txn={}: expected (S={} X={}, IS={}, IX={}, SIX={}), actual (S={} X={}, IS={}, "
"IX={}, "
"SIX={})\n",
txn->GetTransactionId(), s_size, x_size, is_size, ix_size, six_size, txn->GetSharedTableLockSet()->size(),
txn->GetExclusiveTableLockSet()->size(), txn->GetIntentionSharedTableLockSet()->size(),
txn->GetIntentionExclusiveTableLockSet()->size(), txn->GetSharedIntentionExclusiveTableLockSet()->size());
}
EXPECT_TRUE(correct);
}

void TableLockTest1() {
Expand Down

0 comments on commit e0163ed

Please # to comment.