summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-05-20 13:46:50 -0400
committerDavid Storch <david.storch@10gen.com>2015-05-20 17:46:35 -0400
commitb4ad028972a125bdf52b775fb1daa42df0359fc1 (patch)
tree939c4a3ebeaf037de6538f9d4bb48bfde74374c8
parentca3915291cbc7bddb1c81c4fb07196a209f06988 (diff)
downloadmongo-b4ad028972a125bdf52b775fb1daa42df0359fc1.tar.gz
SERVER-16265 add query predicate and aggregation command to the getMore slow query log / profile entries
(cherry picked from commit d89e58fd340ced9370d1a39a4334a42a77005f5e)
-rw-r--r--src/mongo/db/clientcursor.h5
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp4
-rw-r--r--src/mongo/db/query/find.cpp5
3 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index f89eaecd681..ff0173ad0d1 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -153,6 +153,7 @@ namespace mongo {
PlanExecutor* getExecutor() const { return _exec.get(); }
int queryOptions() const { return _queryOptions; }
+ const BSONObj& getQuery() const { return _query; }
// Used by ops/query.cpp to stash how many results have been returned by a query.
int pos() const { return _pos; }
@@ -235,7 +236,9 @@ namespace mongo {
// How many objects have been returned by the find() so far?
int _pos;
- // The query that prompted this ClientCursor. Only used for debugging.
+ // If this cursor was created by a find operation, '_query' holds the query predicate for
+ // the find. If this cursor was created by a command (e.g. the aggregate command), then
+ // '_query' holds the command specification received from the client.
BSONObj _query;
// See the QueryOptions enum in dbclient.h
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 4a0dd6e3699..d75e62e6772 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -129,6 +129,8 @@ namespace mongo {
// cursor (for use by future getmore ops).
cursor->setLeftoverMaxTimeMicros( txn->getCurOp()->getRemainingMaxTimeMicros() );
+ txn->getCurOp()->debug().cursorid = cursor->cursorid();
+
if (txn->getClient()->isInDirectClient()) {
cursor->setUnownedRecoveryUnit(txn->recoveryUnit());
}
@@ -271,7 +273,7 @@ namespace mongo {
execHolder.release(),
nss.ns(),
0,
- BSONObj(),
+ cmdObj.getOwned(),
isAggCursor);
pin.reset(new ClientCursorPin(collection->getCursorManager(),
cursor->cursorid()));
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index dac50778085..512e274c08d 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -309,6 +309,11 @@ namespace mongo {
curop.setMaxTimeMicros(cc->getLeftoverMaxTimeMicros());
txn->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.
+ // Ensure that the original query or command object is available in the slow query log,
+ // profiler, and currentOp.
+ curop.debug().query = cc->getQuery();
+ curop.setQuery(cc->getQuery());
+
if (0 == pass) {
cc->updateSlaveLocation(txn, curop);
}