-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit test for TransactionLockMgr #6599
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cheng-Chang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@cheng-chang has updated the pull request. Re-import the pull request |
@cheng-chang has updated the pull request. Re-import the pull request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cheng-Chang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just some minor comments.
auto txn = NewTxn(); | ||
ASSERT_OK(locker_->TryLock(txn, 1, "k", env_, true)); | ||
ASSERT_OK(locker_->TryLock(txn, 1, "k", env_, false)); | ||
delete txn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think lock downgrade is actually supported, so would be nice to verify that lock is still exclusively locked.
Might be good to do this for some of the other test cases too.
port::Thread BlockUntilWaitingTxn(std::function<void()> f) { | ||
std::atomic<bool> reached(false); | ||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( | ||
"TransactionLockMgr::AcquireWithTimeout:WaitingTxn", | ||
[&](void* /*arg*/) { reached.store(true); }); | ||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); | ||
|
||
port::Thread t(f); | ||
|
||
while (!reached.load()) { | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
} | ||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); | ||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks(); | ||
|
||
return t; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this section should come after the "SharedLocks" test.
@Cheng-Chang merged this pull request in d648a0e. |
Although there are tests related to locking in transaction_test, this new test directly tests against TransactionLockMgr.
Test Plan:
make transaction_lock_mgr_test && ./transaction_lock_mgr_test