Skip to content

Commit 48422af

Browse files
authored
chore: sleep verify thread in release mode (#568)
* chore: sleep verify thread in release mode Signed-off-by: Alex Chi <[email protected]> * fix Signed-off-by: Alex Chi <[email protected]> * fix deadlock detection test Signed-off-by: Alex Chi <[email protected]> --------- Signed-off-by: Alex Chi <[email protected]>
1 parent f9ff12b commit 48422af

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

test/concurrency/deadlock_detection_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ TEST(LockManagerDeadlockDetectionTest, DISABLED_EdgeTest) {
1616
LockManager lock_mgr{};
1717
TransactionManager txn_mgr{&lock_mgr};
1818
lock_mgr.txn_manager_ = &txn_mgr;
19-
lock_mgr.StartDeadlockDetection();
2019

2120
const int num_nodes = 100;
2221
const int num_edges = num_nodes / 2;

tools/terrier_bench/terrier.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ auto main(int argc, char **argv) -> int {
462462
delete txn;
463463

464464
metrics.Report();
465+
466+
if (bustub_nft_num > 1000) {
467+
// if NFT num is large, sleep this thread to avoid lock contention
468+
std::this_thread::sleep_for(std::chrono::seconds(3));
469+
}
465470
}
466471

467472
total_metrics.ReportVerify(metrics.aborted_txn_cnt_, metrics.committed_txn_cnt_);
@@ -494,6 +499,14 @@ auto main(int argc, char **argv) -> int {
494499
bustub->ExecuteSqlTxn(sql, writer, txn);
495500
cnt += std::stoi(ss.str());
496501
}
502+
503+
{
504+
auto writer = bustub::SimpleStreamWriter(std::cout, true);
505+
auto sql = "SELECT count(*) FROM nft WHERE terrier = 0";
506+
std::cout << "SELECT count(*) FROM nft WHERE terrier = 0: ";
507+
bustub->ExecuteSqlTxn(sql, writer, txn);
508+
}
509+
497510
bustub->txn_manager_->Commit(txn);
498511
delete txn;
499512
if (cnt != bustub_nft_num) {

0 commit comments

Comments
 (0)