summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2018-02-27 17:51:41 -0500
committerTess Avitabile <tess.avitabile@mongodb.com>2018-03-02 17:21:41 -0500
commitb1624b3fb1fe7eaf4554682d02c57abc519db819 (patch)
tree87791d227aed63623028ee51dbd6c5f585654962 /src/mongo/db/db_raii.cpp
parent70e200e98474d1a29339bf536f348257e8f83a9d (diff)
downloadmongo-b1624b3fb1fe7eaf4554682d02c57abc519db819.tar.gz
SERVER-33336 Snapshot reads should not take MODE_IX locks when autocommit=true
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index b6fa5158000..6b9a695d02b 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/curop.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/collection_sharding_state.h"
+#include "mongo/db/session_catalog.h"
namespace mongo {
namespace {
@@ -232,9 +233,12 @@ OldClientWriteContext::OldClientWriteContext(OperationContext* opCtx, StringData
LockMode getLockModeForQuery(OperationContext* opCtx) {
invariant(opCtx);
- if (repl::ReadConcernArgs::get(opCtx).getLevel() ==
- repl::ReadConcernLevel::kSnapshotReadConcern) {
- return MODE_IX;
+ // Use IX locks for autocommit:false multi-statement transactions; otherwise, use IS locks.
+ if (opCtx->getWriteUnitOfWork()) {
+ invariant(OperationContextSession::get(opCtx));
+ if (!OperationContextSession::get(opCtx)->getAutocommit()) {
+ return MODE_IX;
+ }
}
return MODE_IS;