summaryrefslogtreecommitdiff
path: root/src/mongo
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:29:58 -0400
commitd89e58fd340ced9370d1a39a4334a42a77005f5e (patch)
tree8a20a1f7f506abb6995dc447c4fae9b87a995abf /src/mongo
parentdefcaffcecef2f3babd4c901e3fdd5573dca39f3 (diff)
downloadmongo-d89e58fd340ced9370d1a39a4334a42a77005f5e.tar.gz
SERVER-16265 add query predicate and aggregation command to the getMore slow query log / profile entries
Diffstat (limited to 'src/mongo')
-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 a94700234d2..f5350ff5707 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -148,6 +148,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; }
@@ -230,7 +231,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 e8ffde68217..813775afff8 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -131,6 +131,8 @@ namespace mongo {
// cursor (for use by future getmore ops).
cursor->setLeftoverMaxTimeMicros( CurOp::get(txn)->getRemainingMaxTimeMicros() );
+ CurOp::get(txn)->debug().cursorid = cursor->cursorid();
+
if (txn->getClient()->isInDirectClient()) {
cursor->setUnownedRecoveryUnit(txn->recoveryUnit());
}
@@ -276,7 +278,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 cf8f2671b3f..d63b7a56667 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -373,6 +373,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);
}