summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/exec/delete.cpp2
-rw-r--r--src/mongo/db/exec/delete.h6
-rw-r--r--src/mongo/db/ops/delete.cpp4
-rw-r--r--src/mongo/db/ops/delete.h3
-rw-r--r--src/mongo/db/ops/delete_executor.cpp21
-rw-r--r--src/mongo/db/ops/delete_request.h6
-rw-r--r--src/mongo/db/query/get_executor.cpp7
-rw-r--r--src/mongo/db/query/get_executor.h2
-rw-r--r--src/mongo/s/d_migrate.cpp30
9 files changed, 55 insertions, 26 deletions
diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp
index 19de5a7a742..3ae6147633e 100644
--- a/src/mongo/db/exec/delete.cpp
+++ b/src/mongo/db/exec/delete.cpp
@@ -112,7 +112,7 @@ namespace mongo {
else {
bool replJustOne = true;
repl::logOp(_txn, "d", _collection->ns().ns().c_str(), deletedDoc, 0,
- &replJustOne);
+ &replJustOne, _params.fromMigrate);
}
}
diff --git a/src/mongo/db/exec/delete.h b/src/mongo/db/exec/delete.h
index 3e24375a5dc..48a783c9b85 100644
--- a/src/mongo/db/exec/delete.h
+++ b/src/mongo/db/exec/delete.h
@@ -36,7 +36,7 @@ namespace mongo {
class OperationContext;
struct DeleteStageParams {
- DeleteStageParams() : isMulti(false), shouldCallLogOp(false) { }
+ DeleteStageParams() : isMulti(false), shouldCallLogOp(false), fromMigrate(false) { }
// Should we delete all documents returned from the child (a "multi delete"), or at most one
// (a "single delete")?
@@ -44,6 +44,10 @@ namespace mongo {
// Should we write each delete to the oplog?
bool shouldCallLogOp;
+
+ // Is this delete part of a migrate operation that is essentially like a no-op
+ // when the cluster is observed by an external client.
+ bool fromMigrate;
};
/**
diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp
index 38b1b2aefe3..bd50b671a14 100644
--- a/src/mongo/db/ops/delete.cpp
+++ b/src/mongo/db/ops/delete.cpp
@@ -44,13 +44,15 @@ namespace mongo {
BSONObj pattern,
bool justOne,
bool logop,
- bool god) {
+ bool god,
+ bool fromMigrate) {
NamespaceString nsString(ns);
DeleteRequest request(txn, nsString);
request.setQuery(pattern);
request.setMulti(!justOne);
request.setUpdateOpLog(logop);
request.setGod(god);
+ request.setFromMigrate(fromMigrate);
DeleteExecutor executor(&request);
return executor.execute(db);
}
diff --git a/src/mongo/db/ops/delete.h b/src/mongo/db/ops/delete.h
index f0536b63dd2..a947167f985 100644
--- a/src/mongo/db/ops/delete.h
+++ b/src/mongo/db/ops/delete.h
@@ -45,6 +45,7 @@ namespace mongo {
BSONObj pattern,
bool justOne,
bool logop = false,
- bool god = false);
+ bool god = false,
+ bool fromMigrate = false);
}
diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp
index 607c13fc4e5..ddb0c29b025 100644
--- a/src/mongo/db/ops/delete_executor.cpp
+++ b/src/mongo/db/ops/delete_executor.cpp
@@ -115,15 +115,24 @@ namespace mongo {
PlanExecutor* rawExec;
if (_canonicalQuery.get()) {
// This is the non-idhack branch.
- uassertStatusOK(getExecutorDelete(_request->getOpCtx(), collection,
- _canonicalQuery.release(), _request->isMulti(),
- _request->shouldCallLogOp(), &rawExec));
+ uassertStatusOK(getExecutorDelete(_request->getOpCtx(),
+ collection,
+ _canonicalQuery.release(),
+ _request->isMulti(),
+ _request->shouldCallLogOp(),
+ _request->isFromMigrate(),
+ &rawExec));
}
else {
// This is the idhack branch.
- uassertStatusOK(getExecutorDelete(_request->getOpCtx(), collection, ns.ns(),
- _request->getQuery(), _request->isMulti(),
- _request->shouldCallLogOp(), &rawExec));
+ uassertStatusOK(getExecutorDelete(_request->getOpCtx(),
+ collection,
+ ns.ns(),
+ _request->getQuery(),
+ _request->isMulti(),
+ _request->shouldCallLogOp(),
+ _request->isFromMigrate(),
+ &rawExec));
}
scoped_ptr<PlanExecutor> exec(rawExec);
diff --git a/src/mongo/db/ops/delete_request.h b/src/mongo/db/ops/delete_request.h
index 3ce0a0bb9fd..53f8d13d475 100644
--- a/src/mongo/db/ops/delete_request.h
+++ b/src/mongo/db/ops/delete_request.h
@@ -44,18 +44,21 @@ namespace mongo {
_nsString(nsString),
_multi(false),
_logop(false),
- _god(false) {}
+ _god(false),
+ _fromMigrate(false) {}
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; }
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; }
OperationContext* getOpCtx() const { return _txn; }
std::string toString() const;
@@ -67,6 +70,7 @@ namespace mongo {
bool _multi;
bool _logop;
bool _god;
+ bool _fromMigrate;
};
} // namespace mongo
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 29480e463db..81e33790e52 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -468,6 +468,7 @@ namespace mongo {
CanonicalQuery* rawCanonicalQuery,
bool isMulti,
bool shouldCallLogOp,
+ bool fromMigrate,
PlanExecutor** out) {
auto_ptr<CanonicalQuery> canonicalQuery(rawCanonicalQuery);
auto_ptr<WorkingSet> ws(new WorkingSet());
@@ -482,6 +483,7 @@ namespace mongo {
DeleteStageParams deleteStageParams;
deleteStageParams.isMulti = isMulti;
deleteStageParams.shouldCallLogOp = shouldCallLogOp;
+ deleteStageParams.fromMigrate = fromMigrate;
root = new DeleteStage(txn, deleteStageParams, ws.get(), collection, root);
// We must have a tree of stages in order to have a valid plan executor, but the query
// solution may be null.
@@ -496,11 +498,13 @@ namespace mongo {
const BSONObj& unparsedQuery,
bool isMulti,
bool shouldCallLogOp,
+ bool fromMigrate,
PlanExecutor** out) {
auto_ptr<WorkingSet> ws(new WorkingSet());
DeleteStageParams deleteStageParams;
deleteStageParams.isMulti = isMulti;
deleteStageParams.shouldCallLogOp = shouldCallLogOp;
+ deleteStageParams.fromMigrate = fromMigrate;
if (!collection) {
LOG(2) << "Collection " << ns << " does not exist."
<< " Using EOF stage: " << unparsedQuery.toString();
@@ -530,7 +534,8 @@ namespace mongo {
return status;
// Takes ownership of 'cq'.
- return getExecutorDelete(txn, collection, cq, isMulti, shouldCallLogOp, out);
+ return getExecutorDelete(txn, collection, cq, isMulti,
+ shouldCallLogOp, fromMigrate, out);
}
//
diff --git a/src/mongo/db/query/get_executor.h b/src/mongo/db/query/get_executor.h
index cb49007260f..bfdb53fe98b 100644
--- a/src/mongo/db/query/get_executor.h
+++ b/src/mongo/db/query/get_executor.h
@@ -144,6 +144,7 @@ namespace mongo {
CanonicalQuery* rawCanonicalQuery,
bool isMulti,
bool shouldCallLogOp,
+ bool fromMigrate,
PlanExecutor** execOut);
/**
@@ -161,6 +162,7 @@ namespace mongo {
const BSONObj& unparsedQuery,
bool isMulti,
bool shouldCallLogOp,
+ bool fromMigrate,
PlanExecutor** execOut);
//
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index 4980327870e..b6011313603 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -61,6 +61,7 @@
#include "mongo/db/field_parser.h"
#include "mongo/db/hasher.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/ops/delete.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/range_deleter_service.h"
#include "mongo/db/repl/oplog.h"
@@ -2140,20 +2141,21 @@ namespace mongo {
}
}
- // id object most likely has form { _id : ObjectId(...) }
- // infer from that correct index to use, e.g. { _id : 1 }
- BSONObj idIndexPattern = Helpers::inferKeyPattern( id );
-
- // TODO: create a better interface to remove objects directly
- KeyRange range( ns, id, id, idIndexPattern );
- const WriteConcernOptions singleNodeWrite(1, WriteConcernOptions::NONE,
- WriteConcernOptions::kNoTimeout);
- Helpers::removeRange( txn,
- range ,
- true , /*maxInclusive*/
- singleNodeWrite,
- serverGlobalParams.moveParanoia ? &rs : 0 , /*callback*/
- true ); /*fromMigrate*/
+ Lock::DBWrite lk(txn->lockState(), ns);
+ Client::Context ctx(txn, ns);
+
+ if (serverGlobalParams.moveParanoia) {
+ rs.goingToDelete(fullObj);
+ }
+
+ deleteObjects(txn,
+ ctx.db(),
+ ns,
+ id,
+ true /* justOne */,
+ true /* logOp */,
+ false /* god */,
+ true /* fromMigrate */);
*lastOpApplied = cx.ctx().getClient()->getLastOp().asDate();
cx.commit();