diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-05-28 13:49:34 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-06-02 22:52:46 -0400 |
commit | 8c9fcc939f9f1a2b593e606bd790cc87efd4064f (patch) | |
tree | beaa313f3e53cf72ca76aa5392946b97736ea6b3 /src/mongo/db/repl/sync.cpp | |
parent | 4add46aa8dd05a5c6d8af2c798eef6e9b5e4164b (diff) | |
download | mongo-8c9fcc939f9f1a2b593e606bd790cc87efd4064f.tar.gz |
SERVER-13961 Start using LockState from the OperationContext
Diffstat (limited to 'src/mongo/db/repl/sync.cpp')
-rw-r--r-- | src/mongo/db/repl/sync.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/repl/sync.cpp b/src/mongo/db/repl/sync.cpp index 8ca15ed9386..16e6225a1fb 100644 --- a/src/mongo/db/repl/sync.cpp +++ b/src/mongo/db/repl/sync.cpp @@ -36,7 +36,6 @@ #include "mongo/db/diskloc.h" #include "mongo/db/pdfile.h" #include "mongo/db/repl/oplogreader.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/catalog/collection.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" @@ -106,16 +105,17 @@ namespace repl { str::stream() << "Can no longer connect to initial sync source: " << hn); } - bool Sync::shouldRetry(const BSONObj& o) { + bool Sync::shouldRetry(OperationContext* txn, const BSONObj& o) { + invariant(txn->lockState()->hasAnyWriteLock()); + // should already have write lock const char *ns = o.getStringField("ns"); Client::Context ctx(ns); - OperationContextImpl txn; // we don't have the object yet, which is possible on initial sync. get it. log() << "replication info adding missing object" << endl; // rare enough we can log - BSONObj missingObj = getMissingDoc(&txn, ctx.db(), o); + BSONObj missingObj = getMissingDoc(txn, ctx.db(), o); if( missingObj.isEmpty() ) { log() << "replication missing object not found on source. presumably deleted later in oplog" << endl; @@ -125,9 +125,10 @@ namespace repl { return false; } else { - Collection* collection = ctx.db()->getOrCreateCollection( &txn, ns ); - verify( collection ); // should never happen - StatusWith<DiskLoc> result = collection->insertDocument( &txn, missingObj, true ); + Collection* collection = ctx.db()->getOrCreateCollection(txn, ns); + invariant(collection != NULL); // should never happen + + StatusWith<DiskLoc> result = collection->insertDocument(txn, missingObj, true); uassert(15917, str::stream() << "failed to insert missing doc: " << result.toString(), result.isOK() ); |