summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2018-08-23 17:50:46 -0400
committerEric Milkie <milkie@10gen.com>2018-08-24 11:38:27 -0400
commit5c1a3ec728a71bca81629f99be782ac305a6ad4b (patch)
tree5e0af4cb4cd2ffbfa8ef80f21210cc56ecf191b3 /src/mongo/db/op_observer_impl.cpp
parentf7c2600036ce876bb389f3eb3adc8eada6932d8b (diff)
downloadmongo-5c1a3ec728a71bca81629f99be782ac305a6ad4b.tar.gz
SERVER-36534 don't acquire locks on oplog when writing oplog entries
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 9117ce32e6c..c391b183635 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -983,6 +983,10 @@ void OpObserverImpl::onTransactionCommit(OperationContext* opCtx, bool wasPrepar
const NamespaceString cmdNss{"admin", "$cmd"};
const auto cmdObj = BSON("commitTransaction" << 1);
TransactionParticipant::SideTransactionBlock sideTxn(opCtx);
+
+ // Writes to the oplog only require a Global intent lock.
+ Lock::GlobalLock globalLock(opCtx, MODE_IX);
+
WriteUnitOfWork wuow(opCtx);
logOperation(opCtx,
"c",
@@ -1031,6 +1035,10 @@ void OpObserverImpl::onTransactionPrepare(OperationContext* opCtx, const OplogSl
// and allow this transaction to be continued on failover.
{
TransactionParticipant::SideTransactionBlock sideTxn(opCtx);
+
+ // Writes to the oplog only require a Global intent lock.
+ Lock::GlobalLock globalLock(opCtx, MODE_IX);
+
WriteUnitOfWork wuow(opCtx);
Session* const session = OperationContextSession::get(opCtx);