diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-10-26 11:08:35 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-11-05 09:58:49 -0500 |
commit | 167861a164723168adfaaa866f310cb94010428f (patch) | |
tree | 93e5d5d74227164c1788e38df924380444d91d40 | |
parent | dfd716ec5e97d70c3114550935a17bdc09b9290c (diff) | |
download | mongo-167861a164723168adfaaa866f310cb94010428f.tar.gz |
SERVER-37313 Secondary foreground index build should take Database X rather than Global X lockr3.6.9-rc0r3.6.9
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 773f3c4da84..4e0474f9031 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -243,6 +243,12 @@ void createIndexForApplyOps(OperationContext* opCtx, const BSONObj& indexSpec, const NamespaceString& indexNss, IncrementOpsAppliedStatsFn incrementOpsAppliedStats) { + // Since 'createIndexes' is a 'c' oplog entry, it takes the Global X lock. However, we don't + // want index build to block FTDC thread which periodically gathers data with Global IS lock. + // Put this hack to release the Global X lock and take the Global IX instead. + Lock::TempRelease tempRelease(opCtx->lockState()); + Lock::DBLock lock(opCtx, indexNss.db(), MODE_X); + // Check if collection exists. Database* db = dbHolder().get(opCtx, indexNss.ns()); auto indexCollection = db ? db->getCollection(opCtx, indexNss) : nullptr; |