summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2023-02-24 15:16:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-24 16:41:32 +0000
commitd5f4a148778c761dbee720106786c8290fec428b (patch)
tree011ac146886cf82b5bebeba5706763a87c101e6f /src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
parent65a835758a41b04cf70bf5c80663e97d33ad7ca0 (diff)
downloadmongo-d5f4a148778c761dbee720106786c8290fec428b.tar.gz
SERVER-65106 Periodically wake to check if prepared transaction has ended
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index 5fbfe2b8a7c..175337a743b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -368,9 +368,17 @@ void WiredTigerSessionCache::waitUntilDurable(OperationContext* opCtx,
void WiredTigerSessionCache::waitUntilPreparedUnitOfWorkCommitsOrAborts(OperationContext* opCtx,
std::uint64_t lastCount) {
invariant(opCtx);
+
+ // It is possible for a prepared transaction to block on bonus eviction inside WiredTiger after
+ // it commits or rolls-back, but this delays it from signalling us to wake up. In the very
+ // worst case that the only evictable page is the one pinned by our cursor, AND there are no
+ // other prepared transactions committing or aborting, we could reach a deadlock. Since the
+ // caller is already expecting spurious wakeups, we impose a large timeout to periodically force
+ // the caller to retry its operation.
+ const auto deadline = Date_t::now() + Seconds(1);
stdx::unique_lock<Latch> lk(_prepareCommittedOrAbortedMutex);
if (lastCount == _prepareCommitOrAbortCounter.loadRelaxed()) {
- opCtx->waitForConditionOrInterrupt(_prepareCommittedOrAbortedCond, lk, [&] {
+ opCtx->waitForConditionOrInterruptUntil(_prepareCommittedOrAbortedCond, lk, deadline, [&] {
return _prepareCommitOrAbortCounter.loadRelaxed() > lastCount;
});
}