diff options
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index ef01eb2b60e..9719dceeeee 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -537,8 +537,6 @@ namespace repl { string threadName = str::stream() << "repl writer worker " << replWriterWorkerId.addAndFetch(1); Client::initThread( threadName.c_str() ); - // allow us to get through the magic barrier - Lock::ParallelBatchWriterMode::iAmABatchParticipant(&cc().lockState()); replLocalAuth(); } } @@ -547,6 +545,11 @@ namespace repl { void multiSyncApply(const std::vector<BSONObj>& ops, SyncTail* st) { initializeWriterThread(); + OperationContextImpl txn; + + // allow us to get through the magic barrier + Lock::ParallelBatchWriterMode::iAmABatchParticipant(txn.lockState()); + // convert update operations only for 2.2.1 or greater, because we need guaranteed // idempotent operations for this to work. See SERVER-6825 bool convertUpdatesToUpserts = theReplSet->oplogVersion > 1 ? true : false; @@ -555,7 +558,6 @@ namespace repl { it != ops.end(); ++it) { try { - OperationContextImpl txn; if (!st->syncApply(&txn, *it, convertUpdatesToUpserts)) { fassertFailedNoTrace(16359); } @@ -570,12 +572,16 @@ namespace repl { // This free function is used by the initial sync writer threads to apply each op void multiInitialSyncApply(const std::vector<BSONObj>& ops, SyncTail* st) { initializeWriterThread(); + + OperationContextImpl txn; + + // allow us to get through the magic barrier + Lock::ParallelBatchWriterMode::iAmABatchParticipant(txn.lockState()); + for (std::vector<BSONObj>::const_iterator it = ops.begin(); it != ops.end(); ++it) { try { - OperationContextImpl txn; - if (!st->syncApply(&txn, *it)) { bool status; { |