diff options
author | James Wahlin <james.wahlin@10gen.com> | 2015-04-09 09:50:49 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2015-04-13 08:31:59 -0400 |
commit | 5cfd95b0eb36c72f1b1b131ff1de76fe05f16cc3 (patch) | |
tree | ea898b373b3cffc915dcc19bbff85da899cda197 /src/mongo | |
parent | 64d7779bdbc5b8e491a0916c92c55d162cbe8745 (diff) | |
download | mongo-5cfd95b0eb36c72f1b1b131ff1de76fe05f16cc3.tar.gz |
SERVER-17332 Add cursorExhausted flag to find/getMore log/prof
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/client.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 1 | ||||
-rw-r--r-- | src/mongo/db/query/find.cpp | 7 |
4 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index bdfdc990d0c..e34d7e155cd 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -197,6 +197,7 @@ namespace mongo { fastmod = false; fastmodinsert = false; upsert = false; + cursorExhausted = false; keyUpdates = 0; // unsigned, so -1 not possible writeConflicts = 0; planSummary = ""; @@ -267,6 +268,7 @@ namespace mongo { OPDEBUG_TOSTRING_HELP_BOOL( fastmod ); OPDEBUG_TOSTRING_HELP_BOOL( fastmodinsert ); OPDEBUG_TOSTRING_HELP_BOOL( upsert ); + OPDEBUG_TOSTRING_HELP_BOOL( cursorExhausted ); OPDEBUG_TOSTRING_HELP( keyUpdates ); OPDEBUG_TOSTRING_HELP( writeConflicts ); @@ -374,6 +376,7 @@ namespace mongo { OPDEBUG_APPEND_BOOL( fastmod ); OPDEBUG_APPEND_BOOL( fastmodinsert ); OPDEBUG_APPEND_BOOL( upsert ); + OPDEBUG_APPEND_BOOL( cursorExhausted ); OPDEBUG_APPEND_NUMBER( keyUpdates ); OPDEBUG_APPEND_NUMBER( writeConflicts ); b.appendNumber("numYield", curop.numYields()); diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index e95505832a0..84d4c76e1a3 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -257,6 +257,9 @@ namespace mongo { ruSwapper.dismiss(); } } + else { + txn->getCurOp()->debug().cursorExhausted = true; + } Command::appendGetMoreResponseObject(respondWithId, request.nss.ns(), nextBatch.arr(), &result); diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 0228d2d6a7a..c6cb57c8a17 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -171,6 +171,7 @@ namespace mongo { bool fastmod; bool fastmodinsert; // upsert of an $operation. builds a default object bool upsert; // true if the update actually did an insert + bool cursorExhausted; // true if the cursor has been closed at end a find/getMore operation int keyUpdates; long long writeConflicts; ThreadSafeString planSummary; // a brief std::string describing the query solution diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index a6a13db1fc8..aff76e168cb 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -197,6 +197,7 @@ namespace mongo { // Fill out basic curop query exec properties. curop->debug().nreturned = numResults; curop->debug().cursorid = (0 == cursorId ? -1 : cursorId); + curop->debug().cursorExhausted = (0 == cursorId); // Fill out curop based on explain summary statistics. PlanSummaryStats summaryStats; @@ -455,6 +456,7 @@ namespace mongo { // cc is now invalid, as is the executor cursorid = 0; cc = NULL; + curop.debug().cursorExhausted = true; LOG(5) << "getMore NOT saving client cursor, ended with state " << PlanExecutor::statestr(state) << endl; @@ -678,7 +680,6 @@ namespace mongo { // Fill out curop based on query results. If we have a cursorid, we will fill out curop with // this cursorid later. long long ccId = 0; - endQueryOp(exec.get(), dbProfilingLevel, numResults, ccId, &curop); if (shouldSaveCursor(txn, collection, state, exec.get())) { // We won't use the executor until it's getMore'd. @@ -727,9 +728,12 @@ namespace mongo { // If the query had a time limit, remaining time is "rolled over" to the cursor (for // use by future getmore ops). cc->setLeftoverMaxTimeMicros(curop.getRemainingMaxTimeMicros()); + + endQueryOp(cc->getExecutor(), dbProfilingLevel, numResults, ccId, &curop); } else { LOG(5) << "Not caching executor but returning " << numResults << " results.\n"; + endQueryOp(exec.get(), dbProfilingLevel, numResults, ccId, &curop); } // Add the results from the query into the output buffer. @@ -739,7 +743,6 @@ namespace mongo { // Fill out the output buffer's header. QueryResult::View qr = result.header().view2ptr(); qr.setCursorId(ccId); - curop.debug().cursorid = (0 == ccId ? -1 : ccId); qr.setResultFlagsToOk(); qr.msgdata().setOperation(opReply); qr.setStartingFrom(0); |