diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2017-03-09 12:34:17 -0500 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2017-03-13 09:02:03 -0400 |
commit | 73f9e8b8a8422becf8694fe3d82c0e647dc71189 (patch) | |
tree | b938d6e3fd63fc00819b72231dfe952b8b212d79 /src/mongo/db/repl/collection_bulk_loader_impl.cpp | |
parent | ba3db7220399aedbb871aa8a18d325a877c30d53 (diff) | |
download | mongo-73f9e8b8a8422becf8694fe3d82c0e647dc71189.tar.gz |
SERVER-26965 Use RAII type for turning off replicated writes
Diffstat (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp')
-rw-r--r-- | src/mongo/db/repl/collection_bulk_loader_impl.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp index 9b1c96ec95b..2732376875a 100644 --- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp +++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp @@ -93,6 +93,9 @@ Status CollectionBulkLoaderImpl::init(Collection* coll, invariant(opCtx); invariant(coll); invariant(opCtx->getClient() == &cc()); + // All writes in CollectionBulkLoaderImpl should be unreplicated. + // The opCtx is accessed indirectly through _secondaryIndexesBlock. + UnreplicatedWritesBlock uwb(opCtx); std::vector<BSONObj> specs(secondaryIndexSpecs); // This enforces the buildIndexes setting in the replica set configuration. _secondaryIndexesBlock->removeExistingIndexes(&specs); @@ -124,6 +127,7 @@ Status CollectionBulkLoaderImpl::insertDocuments(const std::vector<BSONObj>::con return _runTaskReleaseResourcesOnFailure( [begin, end, &count, this](OperationContext* opCtx) -> Status { invariant(opCtx); + UnreplicatedWritesBlock uwb(opCtx); for (auto iter = begin; iter != end; ++iter) { std::vector<MultiIndexBlock*> indexers; @@ -157,6 +161,7 @@ Status CollectionBulkLoaderImpl::commit() { LOG(2) << "Creating indexes for ns: " << _nss.ns(); invariant(opCtx->getClient() == &cc()); invariant(opCtx == _opCtx); + UnreplicatedWritesBlock uwb(opCtx); // Commit before deleting dups, so the dups will be removed from secondary indexes when // deleted. |