summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-01-12 11:15:51 -0500
committerJason Rassi <rassi@10gen.com>2015-01-12 11:25:48 -0500
commitaacb51ba4e1c96de41fc928e58a6341db82076c4 (patch)
tree29d3173ad6bb8b5a5ae75b124b16c1831545b484 /src/mongo
parent4d73df94d51bc86a6a5b30dc3106cd7df6a3b7be (diff)
downloadmongo-aacb51ba4e1c96de41fc928e58a6341db82076c4.tar.gz
SERVER-16657 ClientCursor namespace set explicitly on construction
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/clientcursor.cpp5
-rw-r--r--src/mongo/db/clientcursor.h6
-rw-r--r--src/mongo/db/commands/list_collections.cpp3
-rw-r--r--src/mongo/db/commands/list_indexes.cpp3
-rw-r--r--src/mongo/db/commands/parallel_collection_scan.cpp3
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp5
-rw-r--r--src/mongo/db/commands/repair_cursor.cpp4
-rw-r--r--src/mongo/db/query/find.cpp7
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp9
9 files changed, 30 insertions, 15 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index a98867d6291..50ca7e75d7a 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -72,16 +72,17 @@ namespace mongo {
ClientCursor::ClientCursor(CursorManager* cursorManager,
PlanExecutor* exec,
+ const std::string& ns,
int qopts,
const BSONObj query,
bool isAggCursor)
- : _cursorManager(cursorManager),
+ : _ns(ns),
+ _cursorManager(cursorManager),
_countedYet(false),
_isAggCursor(isAggCursor),
_unownedRU(NULL) {
_exec.reset(exec);
- _ns = exec->ns();
_query = query;
_queryOptions = qopts;
if (exec->collection()) {
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index 9ffe1ac1318..462ae1caa4a 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -62,10 +62,14 @@ namespace mongo {
class ClientCursor : private boost::noncopyable {
public:
/**
- * This ClientCursor constructor creates a cursorid that can be getMore'd
+ * This ClientCursor constructor creates a cursorid that can be used with getMore and
+ * killCursors. "cursorManager" is the object that will manage the lifetime of this
+ * cursor, and "ns" is the namespace string that should be associated with this cursor (e.g.
+ * "test.foo", "test.$cmd.listCollections", etc).
*/
ClientCursor(CursorManager* cursorManager,
PlanExecutor* exec,
+ const std::string& ns,
int qopts = 0,
const BSONObj query = BSONObj(),
bool isAggCursor = false);
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 53f1c880f45..c9938ae7c9e 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -170,7 +170,8 @@ namespace mongo {
if ( !exec->isEOF() ) {
exec->saveState();
ClientCursor* cursor = new ClientCursor(CursorManager::getGlobalCursorManager(),
- exec.release());
+ exec.release(),
+ cursorNamespace);
cursorId = cursor->cursorid();
cursor->setOwnedRecoveryUnit(txn->releaseRecoveryUnit());
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index 3bd6d639604..8cbc97da8f2 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -171,7 +171,8 @@ namespace mongo {
if ( !exec->isEOF() ) {
exec->saveState();
ClientCursor* cursor = new ClientCursor(CursorManager::getGlobalCursorManager(),
- exec.release());
+ exec.release(),
+ cursorNamespace);
cursorId = cursor->cursorid();
cursor->setOwnedRecoveryUnit(txn->releaseRecoveryUnit());
diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp
index 0dc2950f18d..8d1e4f206e9 100644
--- a/src/mongo/db/commands/parallel_collection_scan.cpp
+++ b/src/mongo/db/commands/parallel_collection_scan.cpp
@@ -138,7 +138,8 @@ namespace mongo {
// transfer ownership of an executor to the ClientCursor (which manages its own
// lifetime).
ClientCursor* cc = new ClientCursor( collection->cursorManager(),
- execs.releaseAt(i) );
+ execs.releaseAt(i),
+ ns.ns() );
// we are mimicking the aggregation cursor output here
// that is why there are ns, ok and empty firstBatch
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 848e94b7df8..9061f5978cb 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -281,7 +281,10 @@ namespace mongo {
// XXX
const bool isAggCursor = true; // enable special locking behavior
ClientCursor* cursor = new ClientCursor(collection->cursorManager(),
- execHolder.release(), 0, BSONObj(),
+ execHolder.release(),
+ nss.ns(),
+ 0,
+ BSONObj(),
isAggCursor);
pin.reset(new ClientCursorPin(collection->cursorManager(), cursor->cursorid()));
// Don't add any code between here and the start of the try block.
diff --git a/src/mongo/db/commands/repair_cursor.cpp b/src/mongo/db/commands/repair_cursor.cpp
index 9e97763e0f9..986e35cfc7d 100644
--- a/src/mongo/db/commands/repair_cursor.cpp
+++ b/src/mongo/db/commands/repair_cursor.cpp
@@ -102,7 +102,9 @@ namespace mongo {
// ClientCursors' constructor inserts them into a global map that manages their
// lifetimes. That is why the next line isn't leaky.
- ClientCursor* cc = new ClientCursor(collection->cursorManager(), exec.release());
+ ClientCursor* cc = new ClientCursor(collection->cursorManager(),
+ exec.release(),
+ ns.ns());
BSONObjBuilder cursorObj(result.subobjStart("cursor"));
cursorObj.append("id", cc->cursorid());
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index b6b73e12454..c3d6575ae2d 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -842,7 +842,9 @@ namespace mongo {
// Allocate a new ClientCursor. We don't have to worry about leaking it as it's
// inserted into a global map by its ctor.
- ClientCursor* cc = new ClientCursor(collection->cursorManager(), exec.get(),
+ ClientCursor* cc = new ClientCursor(collection->cursorManager(),
+ exec.release(),
+ nss.ns(),
pq.getOptions().toInt(),
pq.getFilter());
ccId = cc->cursorid();
@@ -865,9 +867,6 @@ namespace mongo {
QLOG() << "caching executor with cursorid " << ccId
<< " after returning " << numResults << " results" << endl;
- // ClientCursor takes ownership of executor. Release to make sure it's not deleted.
- exec.release();
-
// TODO document
if (pq.getOptions().oplogReplay && !slaveReadTill.isNull()) {
cc->slaveReadTill(slaveReadTill);
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index d44e5cfa688..43a2cc1c05b 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -421,7 +421,7 @@ namespace QueryPlanExecutor {
PlanExecutor* exec = makeCollScanExec(coll,filterObj);
// Make a client cursor from the runner.
- new ClientCursor(coll->cursorManager(), exec, 0, BSONObj());
+ new ClientCursor(coll->cursorManager(), exec, ns(), 0, BSONObj());
// There should be one cursor before invalidation,
// and zero cursors after invalidation.
@@ -447,7 +447,10 @@ namespace QueryPlanExecutor {
PlanExecutor* exec = makeCollScanExec(collection, filterObj);
// Make a client cursor from the runner.
- ClientCursor* cc = new ClientCursor(collection->cursorManager(), exec, 0,
+ ClientCursor* cc = new ClientCursor(collection->cursorManager(),
+ exec,
+ ns(),
+ 0,
BSONObj());
ClientCursorPin ccPin(collection->cursorManager(), cc->cursorid());
@@ -488,7 +491,7 @@ namespace QueryPlanExecutor {
PlanExecutor* exec = makeCollScanExec(collection, filterObj);
// Make a client cursor from the runner.
- new ClientCursor(collection->cursorManager(), exec, 0, BSONObj());
+ new ClientCursor(collection->cursorManager(), exec, ns(), 0, BSONObj());
}
// There should be one cursor before timeout,