summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-03-13 06:35:51 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2015-04-09 10:57:16 -0400
commit1725d76f448323a2bbaa11ffd37fd7b10cd6a64b (patch)
treebe35489fd99d5b0040f27d86b731cfcae1e4479a /src/mongo/db/ops
parentacc7a72194990f35ff706bdcab7ec443c39fb0d5 (diff)
downloadmongo-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')
-rw-r--r--src/mongo/db/ops/delete.cpp2
-rw-r--r--src/mongo/db/ops/delete.h1
-rw-r--r--src/mongo/db/ops/delete_request.h4
-rw-r--r--src/mongo/db/ops/parsed_update.cpp4
-rw-r--r--src/mongo/db/ops/update.cpp16
-rw-r--r--src/mongo/db/ops/update_request.h26
6 files changed, 7 insertions, 46 deletions
diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp
index ed53c86e1e8..f7782d14edf 100644
--- a/src/mongo/db/ops/delete.cpp
+++ b/src/mongo/db/ops/delete.cpp
@@ -49,14 +49,12 @@ namespace mongo {
BSONObj pattern,
PlanExecutor::YieldPolicy policy,
bool justOne,
- bool logop,
bool god,
bool fromMigrate) {
NamespaceString nsString(ns);
DeleteRequest request(nsString);
request.setQuery(pattern);
request.setMulti(!justOne);
- request.setUpdateOpLog(logop);
request.setGod(god);
request.setFromMigrate(fromMigrate);
request.setYieldPolicy(policy);
diff --git a/src/mongo/db/ops/delete.h b/src/mongo/db/ops/delete.h
index 7616bb9bcec..70957d988d0 100644
--- a/src/mongo/db/ops/delete.h
+++ b/src/mongo/db/ops/delete.h
@@ -46,7 +46,6 @@ namespace mongo {
BSONObj pattern,
PlanExecutor::YieldPolicy policy,
bool justOne,
- bool logop = false,
bool god = false,
bool fromMigrate = false);
diff --git a/src/mongo/db/ops/delete_request.h b/src/mongo/db/ops/delete_request.h
index 3b3d97328ef..2d2a3f46a0b 100644
--- a/src/mongo/db/ops/delete_request.h
+++ b/src/mongo/db/ops/delete_request.h
@@ -42,7 +42,6 @@ namespace mongo {
explicit DeleteRequest(const NamespaceString& nsString) :
_nsString(nsString),
_multi(false),
- _logop(false),
_god(false),
_fromMigrate(false),
_isExplain(false),
@@ -50,7 +49,6 @@ namespace mongo {
void setQuery(const BSONObj& query) { _query = query; }
void setMulti(bool multi = true) { _multi = multi; }
- void setUpdateOpLog(bool logop = true) { _logop = logop; }
void setGod(bool god = true) { _god = god; }
void setFromMigrate(bool fromMigrate = true) { _fromMigrate = fromMigrate; }
void setExplain(bool isExplain = true) { _isExplain = isExplain; }
@@ -59,7 +57,6 @@ namespace mongo {
const NamespaceString& getNamespaceString() const { return _nsString; }
const BSONObj& getQuery() const { return _query; }
bool isMulti() const { return _multi; }
- bool shouldCallLogOp() const { return _logop; }
bool isGod() const { return _god; }
bool isFromMigrate() const { return _fromMigrate; }
bool isExplain() const { return _isExplain; }
@@ -71,7 +68,6 @@ namespace mongo {
const NamespaceString& _nsString;
BSONObj _query;
bool _multi;
- bool _logop;
bool _god;
bool _fromMigrate;
bool _isExplain;
diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp
index d6a26fdaed2..9e084b2dfe5 100644
--- a/src/mongo/db/ops/parsed_update.cpp
+++ b/src/mongo/db/ops/parsed_update.cpp
@@ -94,12 +94,12 @@ namespace mongo {
// Only user updates should be checked. Any system or replication stuff should pass through.
// Config db docs shouldn't get checked for valid field names since the shard key can have
// a dot (".") in it.
- const bool shouldValidate = !(_request->isFromReplication() ||
+ const bool shouldValidate = !(!_txn->writesAreReplicated() ||
ns.isConfigDB() ||
_request->isFromMigration());
_driver.setLogOp(true);
- _driver.setModOptions(ModifierInterface::Options(_request->isFromReplication(),
+ _driver.setModOptions(ModifierInterface::Options(!_txn->writesAreReplicated(),
shouldValidate));
return _driver.parse(_request->getUpdates(), _request->isMulti());
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();
}
diff --git a/src/mongo/db/ops/update_request.h b/src/mongo/db/ops/update_request.h
index 99649663ece..9f69fdc3142 100644
--- a/src/mongo/db/ops/update_request.h
+++ b/src/mongo/db/ops/update_request.h
@@ -48,9 +48,7 @@ namespace mongo {
, _god(false)
, _upsert(false)
, _multi(false)
- , _callLogOp(false)
, _fromMigration(false)
- , _fromReplication(false)
, _lifecycle(NULL)
, _isExplain(false)
, _storeResultDoc(false)
@@ -103,14 +101,6 @@ namespace mongo {
return _multi;
}
- inline void setUpdateOpLog(bool value = true) {
- _callLogOp = value;
- }
-
- bool shouldCallLogOp() const {
- return _callLogOp;
- }
-
inline void setFromMigration(bool value = true) {
_fromMigration = value;
}
@@ -119,14 +109,6 @@ namespace mongo {
return _fromMigration;
}
- inline void setFromReplication(bool value = true) {
- _fromReplication = value;
- }
-
- bool isFromReplication() const {
- return _fromReplication;
- }
-
inline void setLifecycle(UpdateLifecycle* value) {
_lifecycle = value;
}
@@ -166,9 +148,7 @@ namespace mongo {
<< " god: " << _god
<< " upsert: " << _upsert
<< " multi: " << _multi
- << " callLogOp: " << _callLogOp
<< " fromMigration: " << _fromMigration
- << " fromReplications: " << _fromReplication
<< " isExplain: " << _isExplain;
}
private:
@@ -193,15 +173,9 @@ namespace mongo {
// True if this update is allowed to affect more than one document.
bool _multi;
- // True if the effects of the update should be written to the oplog.
- bool _callLogOp;
-
// True if this update is on behalf of a chunk migration.
bool _fromMigration;
- // True if this update is being applied during the application for the oplog.
- bool _fromReplication;
-
// The lifecycle data, and events used during the update request.
UpdateLifecycle* _lifecycle;