diff options
author | Dwight <dmerriman@gmail.com> | 2009-03-24 12:53:38 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2009-03-24 12:53:38 -0400 |
commit | 2724428604a23c1add69ff64c20ecb2e32167a59 (patch) | |
tree | 39cb8eef20a7d182197a750f08d74fc22bb5ad53 | |
parent | 64ed02b27d62e9b9c38bfca78a0ec76bda8ba5e0 (diff) | |
parent | c27e290116a355836952006681676c35f01f0f58 (diff) | |
download | mongo-2724428604a23c1add69ff64c20ecb2e32167a59.tar.gz |
Merge branch 'master' of git@github.com:mongodb/mongo
-rw-r--r-- | db/dbcommands.cpp | 4 | ||||
-rw-r--r-- | db/namespace.h | 6 | ||||
-rw-r--r-- | db/query.cpp | 21 | ||||
-rw-r--r-- | db/query.h | 2 | ||||
-rw-r--r-- | db/queryoptimizer.cpp | 6 | ||||
-rw-r--r-- | db/queryoptimizer.h | 4 | ||||
-rw-r--r-- | db/repl.cpp | 8 | ||||
-rw-r--r-- | jstests/repl/pair2.js | 4 | ||||
-rw-r--r-- | s/strategy_shard.cpp | 13 |
9 files changed, 36 insertions, 32 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index ac2a5deddb8..f392d1d46c3 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -571,8 +571,8 @@ namespace mongo { virtual bool run(const char *_ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) { string ns = database->name + '.' + cmdObj.findElement(name).valuestr(); string err; - int n = runCount(ns.c_str(), cmdObj, err); - int nn = n; + long long n = runCount(ns.c_str(), cmdObj, err); + long long nn = n; bool ok = true; if ( n < 0 ) { ok = false; diff --git a/db/namespace.h b/db/namespace.h index cec23706294..e105434ff46 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -353,7 +353,7 @@ namespace mongo { set<string> allIndexKeys; void computeIndexKeys(); int writeCount_; - map< QueryPattern, pair< BSONObj, int > > queryCache_; + map< QueryPattern, pair< BSONObj, long long > > queryCache_; string logNS_; bool logValid_; public: @@ -387,10 +387,10 @@ namespace mongo { BSONObj indexForPattern( const QueryPattern &pattern ) { return queryCache_[ pattern ].first; } - int nScannedForPattern( const QueryPattern &pattern ) { + long long nScannedForPattern( const QueryPattern &pattern ) { return queryCache_[ pattern ].second; } - void registerIndexForPattern( const QueryPattern &pattern, const BSONObj &indexKey, int nScanned ) { + void registerIndexForPattern( const QueryPattern &pattern, const BSONObj &indexKey, long long nScanned ) { queryCache_[ pattern ] = make_pair( indexKey, nScanned ); } diff --git a/db/query.cpp b/db/query.cpp index 5ec47125b6e..047247bc5c7 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -96,7 +96,7 @@ namespace mongo { bool justOne_; int count_; int &bestCount_; - int nScanned_; + long long nScanned_; auto_ptr< Cursor > c_; auto_ptr< KeyValJSMatcher > matcher_; }; @@ -369,10 +369,10 @@ namespace mongo { return new UpdateOp(); } auto_ptr< Cursor > c() { return c_; } - int nscanned() const { return nscanned_; } + long long nscanned() const { return nscanned_; } private: auto_ptr< Cursor > c_; - int nscanned_; + long long nscanned_; auto_ptr< KeyValJSMatcher > matcher_; }; @@ -708,11 +708,11 @@ namespace mongo { virtual QueryOp *clone() const { return new CountOp( spec_ ); } - int count() const { return count_; } + long long count() const { return count_; } virtual bool mayRecordPlan() const { return true; } private: BSONObj spec_; - int count_; + long long count_; auto_ptr< Cursor > c_; BSONObj query_; set< string > fields_; @@ -724,7 +724,7 @@ namespace mongo { /* { count: "collectionname"[, query: <query>] } returns -1 on ns does not exist error. */ - int runCount( const char *ns, const BSONObj &cmd, string &err ) { + long long runCount( const char *ns, const BSONObj &cmd, string &err ) { NamespaceDetails *d = nsdetails( ns ); if ( !d ) { err = "ns missing"; @@ -882,7 +882,7 @@ namespace mongo { auto_ptr< Cursor > cursor() { return c_; } auto_ptr< KeyValJSMatcher > matcher() { return matcher_; } int n() const { return n_; } - int nscanned() const { return nscanned_; } + long long nscanned() const { return nscanned_; } bool saveClientCursor() const { return saveClientCursor_; } private: BufBuilder b_; @@ -894,7 +894,7 @@ namespace mongo { set< string > *filter_; bool ordering_; auto_ptr< Cursor > c_; - int nscanned_; + long long nscanned_; int queryOptions_; auto_ptr< KeyValJSMatcher > matcher_; int n_; @@ -918,7 +918,7 @@ namespace mongo { log(2) << "runQuery: " << ns << jsobj << endl; - int nscanned = 0; + long long nscanned = 0; bool wantMore = true; int ntoreturn = _ntoreturn; if ( _ntoreturn < 0 ) { @@ -1016,6 +1016,7 @@ namespace mongo { DoQueryOp &dqo = *o; massert( dqo.exceptionMessage(), dqo.complete() ); n = dqo.n(); + nscanned = dqo.nscanned(); if ( dqo.scanAndOrderRequired() ) ss << " scanAndOrder "; auto_ptr< Cursor > c = dqo.cursor(); @@ -1040,7 +1041,7 @@ namespace mongo { builder.append("cursor", c->toString()); builder.append("startKey", c->prettyStartKey()); builder.append("endKey", c->prettyEndKey()); - builder.append("nscanned", dqo.nscanned()); + builder.append("nscanned", double( dqo.nscanned() ) ); builder.append("n", n); if ( dqo.scanAndOrderRequired() ) builder.append("scanAndOrder", true); diff --git a/db/query.h b/db/query.h index b164848377e..730763ca76f 100644 --- a/db/query.h +++ b/db/query.h @@ -77,7 +77,7 @@ namespace mongo { // If justOne is true, deletedId is set to the id of the deleted object. int deleteObjects(const char *ns, BSONObj pattern, bool justOne, BSONObj *deletedId = 0, bool god=false); - int runCount(const char *ns, const BSONObj& cmd, string& err); + long long runCount(const char *ns, const BSONObj& cmd, string& err); auto_ptr< QueryResult > runQuery(Message& m, stringstream& ss ); diff --git a/db/queryoptimizer.cpp b/db/queryoptimizer.cpp index 0d8f802234c..188e055df08 100644 --- a/db/queryoptimizer.cpp +++ b/db/queryoptimizer.cpp @@ -155,7 +155,7 @@ namespace mongo { return index_->keyPattern(); } - void QueryPlan::registerSelf( int nScanned ) const { + void QueryPlan::registerSelf( long long nScanned ) const { NamespaceDetailsTransient::get( ns() ).registerIndexForPattern( fbs_.pattern( order_ ), indexKey(), nScanned ); } @@ -322,8 +322,8 @@ namespace mongo { return *i; } - int nScanned = 0; - int nScannedBackup = 0; + long long nScanned = 0; + long long nScannedBackup = 0; while( 1 ) { ++nScanned; unsigned errCount = 0; diff --git a/db/queryoptimizer.h b/db/queryoptimizer.h index 0c6db9ce270..5fc7e73a194 100644 --- a/db/queryoptimizer.h +++ b/db/queryoptimizer.h @@ -51,7 +51,7 @@ namespace mongo { const char *ns() const { return fbs_.ns(); } BSONObj query() const { return fbs_.query(); } const FieldBound &bound( const char *fieldName ) const { return fbs_.bound( fieldName ); } - void registerSelf( int nScanned ) const; + void registerSelf( long long nScanned ) const; private: const FieldBoundSet &fbs_; const BSONObj &order_; @@ -132,7 +132,7 @@ namespace mongo { bool usingPrerecordedPlan_; BSONObj hint_; BSONObj order_; - int oldNScanned_; + long long oldNScanned_; bool honorRecordedPlan_; }; diff --git a/db/repl.cpp b/db/repl.cpp index de035fa5d10..eb98f163653 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -547,8 +547,12 @@ namespace mongo { s.save(); } } - else { - massert("--only requires use of --source", dashDashOnly.empty()); + else { + try { + massert("--only requires use of --source", dashDashOnly.empty()); + } catch ( ... ) { + exit( 40 ); + } } if ( replPair ) { diff --git a/jstests/repl/pair2.js b/jstests/repl/pair2.js index b4494e814d9..443dbb99bd5 100644 --- a/jstests/repl/pair2.js +++ b/jstests/repl/pair2.js @@ -33,6 +33,7 @@ doTest = function( signal ) { rz = r.getDB( baseName ).z rz.save( { _id: new ObjectId() } ); + sleep( 5000 ); soonCount( 1 ); assert.eq( 0, l.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok ); @@ -46,8 +47,7 @@ doTest = function( signal ) { l.setSlaveOk(); assert.soon( function() { return 1 == l.getDB( "admin" ).runCommand( { "resync" : 1 } ).ok; } ); - sleep( 3000 ); - + sleep( 8000 ); soonCount( 1001 ); lz = l.getDB( baseName ).z assert.eq( 1, lz.find( { i: 0 } ).count() ); diff --git a/s/strategy_shard.cpp b/s/strategy_shard.cpp index 5f53af25baf..fabcd023988 100644 --- a/s/strategy_shard.cpp +++ b/s/strategy_shard.cpp @@ -102,7 +102,7 @@ namespace mongo { cursorCache.remove( id ); } - void receivedInsert( Request& r , DbMessage& d, ShardManager* manager ){ + void _insert( Request& r , DbMessage& d, ShardManager* manager ){ while ( d.moreJSObjs() ){ BSONObj o = d.nextJsObj(); if ( ! manager->hasShardKey( o ) ){ @@ -116,7 +116,7 @@ namespace mongo { } } - void receivedUpdate( Request& r , DbMessage& d, ShardManager* manager ){ + void _update( Request& r , DbMessage& d, ShardManager* manager ){ int flags = d.pullInt(); BSONObj query = d.nextJsObj(); @@ -138,7 +138,7 @@ namespace mongo { doWrite( dbUpdate , r , s.getServer() ); } - void receivedDelete( Request& r , DbMessage& d, ShardManager* manager ){ + void _delete( Request& r , DbMessage& d, ShardManager* manager ){ int flags = d.pullInt(); bool justOne = flags & 1; @@ -169,7 +169,6 @@ namespace mongo { } virtual void writeOp( int op , Request& r ){ - const char *ns = r.getns(); log(3) << "write: " << ns << endl; @@ -178,13 +177,13 @@ namespace mongo { assert( info ); if ( op == dbInsert ){ - receivedInsert( r , d , info ); + _insert( r , d , info ); } else if ( op == dbUpdate ){ - receivedUpdate( r , d , info ); + _update( r , d , info ); } else if ( op == dbDelete ){ - receivedDelete( r , d , info ); + _delete( r , d , info ); } else { log() << "sharding can't do write op: " << op << endl; |