diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2015-03-13 06:35:51 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-04-09 10:57:16 -0400 |
commit | 1725d76f448323a2bbaa11ffd37fd7b10cd6a64b (patch) | |
tree | be35489fd99d5b0040f27d86b731cfcae1e4479a /src/mongo/db/ops/update.cpp | |
parent | acc7a72194990f35ff706bdcab7ec443c39fb0d5 (diff) | |
download | mongo-1725d76f448323a2bbaa11ffd37fd7b10cd6a64b.tar.gz |
SERVER-17573 move OpObserver calls into the datalayer as much as possible and eliminate repl bools
Diffstat (limited to 'src/mongo/db/ops/update.cpp')
-rw-r--r-- | src/mongo/db/ops/update.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp index 2c828d164c3..ffdc244e42c 100644 --- a/src/mongo/db/ops/update.cpp +++ b/src/mongo/db/ops/update.cpp @@ -41,7 +41,6 @@ #include "mongo/db/clientcursor.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/exec/update.h" -#include "mongo/db/service_context.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/op_observer.h" #include "mongo/db/ops/update_driver.h" @@ -79,24 +78,19 @@ namespace mongo { ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock lk(txn->lockState(), nsString.db(), MODE_X); - if (!request.isFromReplication() && - !repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase( - nsString.db())) { + bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() && + !repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(nsString.db()); + + if (userInitiatedWritesAndNotPrimary) { uassertStatusOK(Status(ErrorCodes::NotMaster, str::stream() << "Not primary while creating collection " << nsString.ns() << " during upsert")); } WriteUnitOfWork wuow(txn); - collection = db->createCollection(txn, nsString.ns()); + collection = db->createCollection(txn, nsString.ns(), CollectionOptions()); invariant(collection); - if (!request.isFromReplication()) { - getGlobalServiceContext()->getOpObserver()->onCreateCollection( - txn, - NamespaceString(nsString), - CollectionOptions()); - } wuow.commit(); } |