diff options
author | David Storch <david.storch@10gen.com> | 2015-05-20 13:46:50 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2015-05-20 18:14:19 -0400 |
commit | 3e43c6efd8580ccc155e822d3d37dbc115494bc1 (patch) | |
tree | 4dd9bd2dfff12da96a0d708425e28526f9c242d7 | |
parent | 137b088130d7f7fd4ebc8b09d79ed72de44925b5 (diff) | |
download | mongo-3e43c6efd8580ccc155e822d3d37dbc115494bc1.tar.gz |
SERVER-16265 add query predicate and aggregation command to the getMore slow query log / profile entries
(cherry picked from commit d89e58fd340ced9370d1a39a4334a42a77005f5e)
Conflicts:
src/mongo/db/commands/pipeline_command.cpp
src/mongo/db/query/find.cpp
-rw-r--r-- | src/mongo/db/clientcursor.h | 5 | ||||
-rw-r--r-- | src/mongo/db/commands/pipeline_command.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/query/new_find.cpp | 5 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index bbd1e73af9e..26aed634556 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -127,6 +127,7 @@ namespace mongo { Runner* getRunner() const { return _runner.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; } @@ -181,7 +182,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 3926026404f..8763fda4b7b 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -238,6 +238,8 @@ namespace { // If a time limit was set on the pipeline, remaining time is "rolled over" to the // cursor (for use by future getmore ops). cursor->setLeftoverMaxTimeMicros( cc().curop()->getRemainingMaxTimeMicros() ); + + cc().curop()->debug().cursorid = cursor->cursorid(); } BSONObjBuilder cursorObj(result.subobjStart("cursor")); @@ -333,7 +335,11 @@ namespace { } if (collection) { - ClientCursor* cursor = new ClientCursor(collection, runnerHolder.release()); + ClientCursor* cursor = new ClientCursor(collection, + runnerHolder.release(), + 0, /* queryOptions */ + cmdObj.getOwned()); + cursor->isAggCursor = true; // enable special locking behavior pin.reset(new ClientCursorPin(collection, cursor->cursorid())); // Don't add any code between here and the start of the try block. diff --git a/src/mongo/db/query/new_find.cpp b/src/mongo/db/query/new_find.cpp index 9cb98f3f57f..b2214008a7a 100644 --- a/src/mongo/db/query/new_find.cpp +++ b/src/mongo/db/query/new_find.cpp @@ -199,6 +199,11 @@ namespace mongo { curop.setMaxTimeMicros(cc->getLeftoverMaxTimeMicros()); killCurrentOp.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()); + // TODO: What is pass? if (0 == pass) { cc->updateSlaveLocation(curop); } |