Skip to content

Instantly share code, notes, and snippets.

@ajdavis
Created March 12, 2019 19:08
Show Gist options
  • Save ajdavis/2855288b5944700e5093ebe3efbf0a8a to your computer and use it in GitHub Desktop.
Save ajdavis/2855288b5944700e5093ebe3efbf0a8a to your computer and use it in GitHub Desktop.
Test TransactionParticipant::getOldestActiveTimestamp timeout
class TimeoutInGetOldestTransactionTimestamp : public MultiDocumentTransactionTest {
public:
TimeoutInGetOldestTransactionTimestamp()
: MultiDocumentTransactionTest("timeoutInGetOldestTransactionTimestamp") {}
void run() {
auto txnParticipant = TransactionParticipant::get(_opCtx);
ASSERT(txnParticipant);
AutoGetCollection txns(
_opCtx, NamespaceString::kSessionTransactionsTableNamespace, LockMode::MODE_X);
auto task = stdx::packaged_task<void()>([=] {
TransactionParticipant::getOldestActiveTimestamp(Timestamp(0, 0));
});
auto result = task.get_future();
stdx::thread t(std::move(task));
auto mockClock =
static_cast<ClockSourceMock*>(_opCtx->getServiceContext()->getFastClockSource());
mockClock->advance(Seconds(1));
t.join();
result.get();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment