summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2021-07-13 13:46:27 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-07-13 14:27:00 +0000
commit5a2e80c11092052b88ddaffe002ca32438b1fe5a (patch)
tree08bb72c5828ba00c0942da592101f910fbd454d1 /src/mongo/db/concurrency
parent4647a428aa53b84dc2b619e87875eff6653d7b08 (diff)
downloadmongo-5a2e80c11092052b88ddaffe002ca32438b1fe5a.tar.gz
SERVER-48129 Invariant that operations which are holding open an oplog hole cannot block when acquiring locks
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index 6aea85b7d60..eb833039667 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -840,6 +840,14 @@ void LockerImpl::restoreLockState(OperationContext* opCtx, const Locker::LockSna
LockResult LockerImpl::_lockBegin(OperationContext* opCtx, ResourceId resId, LockMode mode) {
dassert(!getWaitingResource().isValid());
+ // Operations which are holding open an oplog hole cannot block when acquiring locks.
+ if (opCtx && !shouldAllowLockAcquisitionOnTimestampedUnitOfWork()) {
+ invariant(!opCtx->recoveryUnit()->isTimestamped(),
+ str::stream()
+ << "Operation holding open an oplog hole tried to acquire locks. ResourceId: "
+ << resId << ", mode: " << modeName(mode));
+ }
+
LockRequest* request;
bool isNew = true;
@@ -918,6 +926,15 @@ void LockerImpl::_lockComplete(OperationContext* opCtx,
ResourceId resId,
LockMode mode,
Date_t deadline) {
+ // Operations which are holding open an oplog hole cannot block when acquiring locks. Lock
+ // requests entering this function have been queued up and will be granted the lock as soon as
+ // the lock is released, which is a blocking operation.
+ if (opCtx && !shouldAllowLockAcquisitionOnTimestampedUnitOfWork()) {
+ invariant(!opCtx->recoveryUnit()->isTimestamped(),
+ str::stream()
+ << "Operation holding open an oplog hole tried to acquire locks. ResourceId: "
+ << resId << ", mode: " << modeName(mode));
+ }
// Clean up the state on any failed lock attempts.
auto unlockOnErrorGuard = makeGuard([&] {