diff options
author | Benety Goh <benety@mongodb.com> | 2018-03-02 13:04:56 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2018-03-02 13:05:16 -0500 |
commit | 522c306f159e4cd741068a20a3e82c7a8bcc26af (patch) | |
tree | e2dc2fe625d04c1140b78668d2436f4edf05e001 /src/mongo/db/index_builder.cpp | |
parent | 6618ad302577418504e9a1b7849bfa7d400d4c53 (diff) | |
download | mongo-522c306f159e4cd741068a20a3e82c7a8bcc26af.tar.gz |
SERVER-33563 add RAII-style class to opt out of replication's use of ParallelBatchWriterMode
Diffstat (limited to 'src/mongo/db/index_builder.cpp')
-rw-r--r-- | src/mongo/db/index_builder.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index bde3e35dd1d..0a6249ea830 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -82,24 +82,23 @@ void IndexBuilder::run() { Client::initThread(name().c_str()); LOG(2) << "IndexBuilder building index " << _index; - const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); - OperationContext& opCtx = *opCtxPtr; - opCtx.lockState()->setShouldConflictWithSecondaryBatchApplication(false); + auto opCtx = cc().makeOperationContext(); + ShouldNotConflictWithSecondaryBatchApplicationBlock shouldNotConflictBlock(opCtx->lockState()); - AuthorizationSession::get(opCtx.getClient())->grantInternalAuthorization(); + AuthorizationSession::get(opCtx->getClient())->grantInternalAuthorization(); { - stdx::lock_guard<Client> lk(*opCtx.getClient()); - CurOp::get(opCtx)->setNetworkOp_inlock(dbInsert); + stdx::lock_guard<Client> lk(*(opCtx->getClient())); + CurOp::get(opCtx.get())->setNetworkOp_inlock(dbInsert); } NamespaceString ns(_index["ns"].String()); - Lock::DBLock dlk(&opCtx, ns.db(), MODE_X); - OldClientContext ctx(&opCtx, ns.getSystemIndexesCollection()); + Lock::DBLock dlk(opCtx.get(), ns.db(), MODE_X); + OldClientContext ctx(opCtx.get(), ns.getSystemIndexesCollection()); - Database* db = dbHolder().get(&opCtx, ns.db().toString()); + Database* db = dbHolder().get(opCtx.get(), ns.db().toString()); - Status status = _build(&opCtx, db, true, &dlk); + Status status = _build(opCtx.get(), db, true, &dlk); if (!status.isOK()) { error() << "IndexBuilder could not build index: " << redact(status); fassert(28555, ErrorCodes::isInterruption(status.code())); |