summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2010-06-05 22:37:59 -0400
committerdwight <dwight@10gen.com>2010-06-05 22:37:59 -0400
commita3e03d7fe8900f6ea328b3c878e89bad068bc438 (patch)
tree89507d5d85337b422c1982b637ee422529457a0c
parentd7bca8d38078a1d69977ef82e97b8835997956f9 (diff)
downloadmongo-a3e03d7fe8900f6ea328b3c878e89bad068bc438.tar.gz
towards QueryOption_exhaust
-rw-r--r--db/db.cpp12
-rw-r--r--db/instance.cpp6
-rw-r--r--db/instance.h4
-rw-r--r--db/query.cpp26
-rw-r--r--db/query.h2
-rw-r--r--tools/restore.cpp2
6 files changed, 30 insertions, 22 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 7fcbebd211a..7f7bc0c6ec1 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -193,7 +193,7 @@ namespace mongo {
DbResponse dbresponse;
if ( !assembleResponse( m, dbresponse, dbMsgPort->farEnd ) ) {
- out() << curTimeMillis() % 10000 << " end msg " << dbMsgPort->farEnd.toString() << endl;
+ log() << curTimeMillis() % 10000 << " end msg " << dbMsgPort->farEnd.toString() << endl;
/* todo: we may not wish to allow this, even on localhost: very low priv accounts could stop us. */
if ( dbMsgPort->farEnd.isLocalHost() ) {
dbMsgPort->shutdown();
@@ -202,12 +202,18 @@ namespace mongo {
dbexit(EXIT_CLEAN);
}
else {
- out() << " (not from localhost, ignoring end msg)" << endl;
+ log() << " (not from localhost, ignoring end msg)" << endl;
}
}
- if ( dbresponse.response )
+ if ( dbresponse.response ) {
dbMsgPort->reply(m, *dbresponse.response, dbresponse.responseTo);
+ if( dbresponse.exhaust ) {
+ while( 1 ) {
+ log() << "exhausting" << endl;
+ }
+ }
+ }
}
}
diff --git a/db/instance.cpp b/db/instance.cpp
index d9872bb85b6..9cc9298b84b 100644
--- a/db/instance.cpp
+++ b/db/instance.cpp
@@ -172,7 +172,7 @@ namespace mongo {
CurOp& op = *(c.curop());
try {
- runQuery(m, q, op, *resp);
+ dbresponse.exhaust = runQuery(m, q, op, *resp);
assert( !resp->empty() );
}
catch ( AssertionException& e ) {
@@ -282,7 +282,7 @@ namespace mongo {
bool log = logLevel >= 1;
if ( op == dbQuery ) {
- receivedQuery(c , dbresponse, m );
+ receivedQuery(c , dbresponse, m ); //zzz
}
else if ( op == dbGetMore ) {
//DEV log = true;
@@ -349,7 +349,7 @@ namespace mongo {
int ms = currentOp.totalTimeMillis();
log = log || (logLevel >= 2 && ++ctr % 512 == 0);
- //DEV log = true;
+ //DEV log = true;
if ( log || ms > logThreshold ) {
if( logLevel < 3 && op == dbGetMore && strstr(ns, ".oplog.") && ms < 3000 && !log ) {
/* it's normal for getMore on the oplog to be slow because of use of awaitdata flag. */
diff --git a/db/instance.h b/db/instance.h
index fc3cd43f852..9356dd3d630 100644
--- a/db/instance.h
+++ b/db/instance.h
@@ -93,10 +93,12 @@ namespace mongo {
struct DbResponse {
Message *response;
MSGID responseTo;
- DbResponse(Message *r, MSGID rt) : response(r), responseTo(rt) {
+ bool exhaust;
+ DbResponse(Message *r, MSGID rt) : response(r), responseTo(rt), exhaust(false) {
}
DbResponse() {
response = 0;
+ exhaust = false;
}
~DbResponse() {
delete response;
diff --git a/db/query.cpp b/db/query.cpp
index 464efb79faf..a4c5835cfca 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -769,7 +769,7 @@ namespace mongo {
};
/* run a query -- includes checking for and running a Command */
- void runQuery(Message& m, QueryMessage& q, CurOp& curop, Message &result) {
+ bool runQuery(Message& m, QueryMessage& q, CurOp& curop, Message &result) {
StringBuilder& ss = curop.debug().str;
shared_ptr<ParsedQuery> pq_shared( new ParsedQuery(q) );
ParsedQuery& pq( *pq_shared );
@@ -790,7 +790,7 @@ namespace mongo {
}
curop.setQuery(jsobj);
- if ( pq.couldBeCommand() ){
+ if ( pq.couldBeCommand() ) {
BufBuilder bb;
bb.skip(sizeof(QueryResult));
BSONObjBuilder cmdResBuf;
@@ -809,7 +809,7 @@ namespace mongo {
qr->nReturned = 1;
result.setData( qr.release(), true );
}
- return;
+ return false;
}
/* --- regular query --- */
@@ -843,10 +843,11 @@ namespace mongo {
if ( pq.hasOption( QueryOption_CursorTailable ) ) {
NamespaceDetails *d = nsdetails( ns );
uassert( 13051, "tailable cursor requested on non capped collection", d && d->capped );
+ const BSONObj nat1 = BSON( "$natural" << 1 );
if ( order.isEmpty() ) {
- order = BSON( "$natural" << 1 );
+ order = nat1;
} else {
- uassert( 13052, "only {$natural:1} order allowed for tailable cursor", order == BSON( "$natural" << 1 ) );
+ uassert( 13052, "only {$natural:1} order allowed for tailable cursor", order == nat1 );
}
}
@@ -899,7 +900,7 @@ namespace mongo {
qr->startingFrom = 0;
qr->nReturned = n;
result.setData( qr.release(), true );
- return;
+ return false;
}
}
@@ -935,6 +936,7 @@ namespace mongo {
if( logLevel >= 5 )
log() << " used cursor: " << cursor.get() << endl;
long long cursorid = 0;
+ bool exhaust = false;
if ( dqo.saveClientCursor() || mps->mayRunMore() ) {
ClientCursor *cc;
bool moreClauses = mps->mayRunMore();
@@ -947,17 +949,15 @@ namespace mongo {
}
cursorid = cc->cursorid;
cc->query = jsobj.getOwned();
- DEV tlog() << " query has more, cursorid: " << cursorid << endl;
+ DEV tlog() << "query has more, cursorid: " << cursorid << endl;
cc->pos = n;
cc->pq = pq_shared;
cc->fields = pq.getFieldPtr();
cc->originalMessage = m;
cc->updateLocation();
- if ( !cc->c->ok() && cc->c->tailable() ) {
- DEV tlog() << " query has no more but tailable, cursorid: " << cursorid << endl;
- } else {
- DEV tlog() << " query has more, cursorid: " << cursorid << endl;
- }
+ if ( !cc->c->ok() && cc->c->tailable() )
+ DEV tlog() << "query has no more but tailable, cursorid: " << cursorid << endl;
+ exhaust = queryOptions & QueryOption_Exhaust;
}
QueryResult *qr = (QueryResult *) result.header();
@@ -980,7 +980,7 @@ namespace mongo {
ss << jsobj << ' ';
}
ss << " nreturned:" << n;
- return;
+ return exhaust;
}
} // namespace mongo
diff --git a/db/query.h b/db/query.h
index f56abf30302..663e68811ef 100644
--- a/db/query.h
+++ b/db/query.h
@@ -114,7 +114,7 @@ namespace mongo {
long long runCount(const char *ns, const BSONObj& cmd, string& err);
- void runQuery(Message& m, QueryMessage& q, CurOp& curop, Message &result);
+ bool runQuery(Message& m, QueryMessage& q, CurOp& curop, Message &result);
/* This is for languages whose "objects" are not well ordered (JSON is well ordered).
[ { a : ... } , { b : ... } ] -> { a : ..., b : ... }
diff --git a/tools/restore.cpp b/tools/restore.cpp
index 1df06f1b358..14dd9ef5091 100644
--- a/tools/restore.cpp
+++ b/tools/restore.cpp
@@ -114,7 +114,7 @@ public:
return;
}
- out() << root.string() << endl;
+ log() << root.string() << endl;
string ns;
if (use_db) {