summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2016-04-05 09:33:23 -0400
committerJames Wahlin <james.wahlin@10gen.com>2016-04-21 11:45:40 -0400
commit6bbaee174447ee1c9177c72bdd07f050ab07e901 (patch)
tree213a1b76b23f31c143fb8ac4f3299fb1e13fc8a9 /src/mongo/db/commands
parent223c2a1aa5fd11fd3e7115ca9acb6d1217f80f92 (diff)
downloadmongo-6bbaee174447ee1c9177c72bdd07f050ab07e901.tar.gz
SERVER-23271 Add keysInserted and keysDeleted metrics for CRUD ops
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp17
-rw-r--r--src/mongo/db/commands/mr.cpp10
-rw-r--r--src/mongo/db/commands/test_commands.cpp3
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp10
-rw-r--r--src/mongo/db/commands/write_commands/write_commands.cpp8
5 files changed, 30 insertions, 18 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 17f4b3d6be5..7d89e39e548 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -245,6 +245,7 @@ public:
const FindAndModifyRequest& args = parseStatus.getValue();
const NamespaceString& nsString = args.getNamespaceString();
+ OpDebug* opDebug = &CurOp::get(txn)->debug();
if (args.isRemove()) {
DeleteRequest request(nsString);
@@ -269,7 +270,8 @@ public:
css->checkShardVersionOrThrow(txn);
Collection* const collection = autoColl.getCollection();
- auto statusWithPlanExecutor = getExecutorDelete(txn, collection, &parsedDelete);
+ auto statusWithPlanExecutor =
+ getExecutorDelete(txn, opDebug, collection, &parsedDelete);
if (!statusWithPlanExecutor.isOK()) {
return statusWithPlanExecutor.getStatus();
}
@@ -288,8 +290,6 @@ public:
return parsedUpdateStatus;
}
- OpDebug* opDebug = &CurOp::get(txn)->debug();
-
// Explain calls of the findAndModify command are read-only, but we take write
// locks so that the timing information is more accurate.
AutoGetCollection autoColl(txn, nsString, MODE_IX);
@@ -303,7 +303,7 @@ public:
Collection* collection = autoColl.getCollection();
auto statusWithPlanExecutor =
- getExecutorUpdate(txn, collection, &parsedUpdate, opDebug);
+ getExecutorUpdate(txn, opDebug, collection, &parsedUpdate);
if (!statusWithPlanExecutor.isOK()) {
return statusWithPlanExecutor.getStatus();
}
@@ -353,6 +353,8 @@ public:
lastOpSetterGuard.Dismiss();
}
+ OpDebug* opDebug = &CurOp::get(txn)->debug();
+
// Although usually the PlanExecutor handles WCE internally, it will throw WCEs when it is
// executing a findAndModify. This is done to ensure that we can always match, modify, and
// return the document under concurrency, if a matching document exists.
@@ -387,7 +389,8 @@ public:
}
Collection* const collection = autoDb.getDb()->getCollection(nsString.ns());
- auto statusWithPlanExecutor = getExecutorDelete(txn, collection, &parsedDelete);
+ auto statusWithPlanExecutor =
+ getExecutorDelete(txn, opDebug, collection, &parsedDelete);
if (!statusWithPlanExecutor.isOK()) {
return appendCommandStatus(result, statusWithPlanExecutor.getStatus());
}
@@ -425,8 +428,6 @@ public:
return appendCommandStatus(result, parsedUpdateStatus);
}
- OpDebug* opDebug = &CurOp::get(txn)->debug();
-
AutoGetOrCreateDb autoDb(txn, dbName, MODE_IX);
Lock::CollectionLock collLock(txn->lockState(), nsString.ns(), MODE_IX);
@@ -476,7 +477,7 @@ public:
}
auto statusWithPlanExecutor =
- getExecutorUpdate(txn, collection, &parsedUpdate, opDebug);
+ getExecutorUpdate(txn, opDebug, collection, &parsedUpdate);
if (!statusWithPlanExecutor.isOK()) {
return appendCommandStatus(result, statusWithPlanExecutor.getStatus());
}
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 8f125382095..155525578ee 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -707,7 +707,10 @@ void State::insert(const string& ns, const BSONObj& o) {
if (!res.getValue().isEmpty()) {
bo = res.getValue();
}
- uassertStatusOK(coll->insertDocument(_txn, bo, true));
+
+ // TODO: Consider whether to pass OpDebug for stats tracking under SERVER-23261.
+ OpDebug* const nullOpDebug = nullptr;
+ uassertStatusOK(coll->insertDocument(_txn, bo, nullOpDebug, true));
wuow.commit();
}
MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insert", ns);
@@ -737,7 +740,10 @@ void State::_insertToInc(BSONObj& o) {
<< ". size in bytes: " << o.objsize()
<< ", max size: " << BSONObjMaxUserSize);
}
- uassertStatusOK(coll->insertDocument(_txn, o, true, false));
+
+ // TODO: Consider whether to pass OpDebug for stats tracking under SERVER-23261.
+ OpDebug* const nullOpDebug = nullptr;
+ uassertStatusOK(coll->insertDocument(_txn, o, nullOpDebug, true, false));
wuow.commit();
}
MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insertToInc", _config.incLong);
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index b286aa3f252..5bcfe71e365 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -101,7 +101,8 @@ public:
return false;
}
}
- Status status = collection->insertDocument(txn, obj, false);
+ OpDebug* const nullOpDebug = nullptr;
+ Status status = collection->insertDocument(txn, obj, nullOpDebug, false);
if (status.isOK()) {
wunit.commit();
}
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index e20696f3394..7886c225b2a 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -929,7 +929,8 @@ static void insertOne(WriteBatchExecutor::ExecInsertsState* state, WriteOpResult
state->getCollection()->ns().ns(), MODE_IX));
WriteUnitOfWork wunit(txn);
- Status status = state->getCollection()->insertDocument(txn, insertDoc, true);
+ Status status = state->getCollection()->insertDocument(
+ txn, insertDoc, &CurOp::get(txn)->debug(), true);
if (status.isOK()) {
result->getStats().n++;
@@ -1118,7 +1119,7 @@ static void multiUpdate(OperationContext* txn,
try {
invariant(collection);
std::unique_ptr<PlanExecutor> exec =
- uassertStatusOK(getExecutorUpdate(txn, collection, &parsedUpdate, debug));
+ uassertStatusOK(getExecutorUpdate(txn, debug, collection, &parsedUpdate));
uassertStatusOK(exec->executePlan());
@@ -1205,6 +1206,8 @@ static void multiRemove(OperationContext* txn,
lastOpSetterGuard.Dismiss();
}
+ OpDebug* opDebug = &CurOp::get(txn)->debug();
+
int attempt = 1;
while (1) {
try {
@@ -1239,7 +1242,7 @@ static void multiRemove(OperationContext* txn,
auto collection = autoDb.getDb()->getCollection(nss);
std::unique_ptr<PlanExecutor> exec =
- uassertStatusOK(getExecutorDelete(txn, collection, &parsedDelete));
+ uassertStatusOK(getExecutorDelete(txn, opDebug, collection, &parsedDelete));
// Execute the delete and retrieve the number deleted.
uassertStatusOK(exec->executePlan());
@@ -1250,6 +1253,7 @@ static void multiRemove(OperationContext* txn,
if (collection) {
collection->infoCache()->notifyOfQuery(txn, summary.indexesUsed);
}
+
CurOp::get(txn)->debug().setPlanSummaryMetrics(summary);
if (repl::ReplClientInfo::forClient(client).getLastOp() != lastOpAtOperationStart) {
diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp
index 7e56675ef3c..ee86ad4be96 100644
--- a/src/mongo/db/commands/write_commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands/write_commands.cpp
@@ -178,6 +178,8 @@ Status WriteCmd::explain(OperationContext* txn,
// Get a reference to the singleton batch item (it's the 0th item in the batch).
BatchItemRef batchItem(&request, 0);
+ OpDebug* opDebug = &CurOp::get(txn)->debug();
+
if (BatchedCommandRequest::BatchType_Update == _writeType) {
// Create the update request.
UpdateRequest updateRequest(request.getNS());
@@ -192,8 +194,6 @@ Status WriteCmd::explain(OperationContext* txn,
// Explained updates can yield.
updateRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO);
- OpDebug* debug = &CurOp::get(txn)->debug();
-
ParsedUpdate parsedUpdate(txn, &updateRequest);
Status parseStatus = parsedUpdate.parseRequest();
if (!parseStatus.isOK()) {
@@ -212,7 +212,7 @@ Status WriteCmd::explain(OperationContext* txn,
}
std::unique_ptr<PlanExecutor> exec =
- uassertStatusOK(getExecutorUpdate(txn, collection, &parsedUpdate, debug));
+ uassertStatusOK(getExecutorUpdate(txn, opDebug, collection, &parsedUpdate));
// Explain the plan tree.
Explain::explainStages(exec.get(), verbosity, out);
@@ -248,7 +248,7 @@ Status WriteCmd::explain(OperationContext* txn,
}
std::unique_ptr<PlanExecutor> exec =
- uassertStatusOK(getExecutorDelete(txn, collection, &parsedDelete));
+ uassertStatusOK(getExecutorDelete(txn, opDebug, collection, &parsedDelete));
// Explain the plan tree.
Explain::explainStages(exec.get(), verbosity, out);