0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

when scanning serially, if a chunk had no results, stopped prematurely SHARDING-71

This commit is contained in:
Eliot Horowitz 2010-01-15 01:27:01 -05:00
parent f8be8a7529
commit 1ba0144d4f
5 changed files with 31 additions and 5 deletions

View File

@ -98,12 +98,18 @@ namespace mongo {
if ( _current.get() && _current->more() )
return true;
if ( _serverIndex >= _servers.size() )
if ( _serverIndex >= _servers.size() ){
return false;
}
ServerAndQuery& sq = _servers[_serverIndex++];
_current = query( sq._server , 0 , sq._extra );
return _current->more();
if ( _current->more() )
return true;
// this sq has nothing, so keep looking
return more();
}
BSONObj SerialServerClusteredCursor::next(){

View File

@ -40,6 +40,8 @@ namespace mongo {
static BSONObj concatQuery( const BSONObj& query , const BSONObj& extraFilter );
virtual string type() const = 0;
protected:
auto_ptr<DBClientCursor> query( const string& server , int num = 0 , BSONObj extraFilter = BSONObj() );
@ -80,6 +82,10 @@ namespace mongo {
return ss.str();
}
operator string() const {
return toString();
}
string _server;
BSONObj _extra;
BSONObj _orderObject;
@ -95,6 +101,7 @@ namespace mongo {
SerialServerClusteredCursor( set<ServerAndQuery> servers , QueryMessage& q , int sortOrder=0);
virtual bool more();
virtual BSONObj next();
virtual string type() const { return "SerialServer"; }
private:
vector<ServerAndQuery> _servers;
unsigned _serverIndex;
@ -115,6 +122,7 @@ namespace mongo {
virtual ~ParallelSortClusteredCursor();
virtual bool more();
virtual BSONObj next();
virtual string type() const { return "ParallelSort"; }
private:
void _init();

View File

@ -8,7 +8,7 @@ placeCheck = function( num ){
print("shard2 step: " + num );
}
s = new ShardingTest( "shard2" , 2 , 5 );
s = new ShardingTest( "shard2" , 2 , 6 );
db = s.getDB( "test" );
@ -142,6 +142,15 @@ function countCursor( c ){
assert.eq( 6 , countCursor( db.foo.find()._exec() ) , "getMore 2" );
assert.eq( 6 , countCursor( db.foo.find().limit(1)._exec() ) , "getMore 3" );
// find by non-shard-key
db.foo.find().forEach(
function(z){
var y = db.foo.findOne( { _id : z._id } );
assert( y , "_id check 1 : " + tojson( z ) );
assert.eq( z.num , y.num , "_id check 2 : " + tojson( z ) );
}
);
// update
person = db.foo.findOne( { num : 3 } );
assert.eq( "bob" , person.name , "update setup 1" );

View File

@ -50,8 +50,9 @@ namespace mongo {
b.append( (void*)o.objdata() , o.objsize() );
num++;
if ( b.len() > maxSize )
if ( b.len() > maxSize ){
break;
}
if ( num == ntoreturn ){
// soft limit aka batch size

View File

@ -37,7 +37,7 @@ namespace mongo {
num++;
}
if ( logLevel > 3 ){
if ( logLevel > 4 ){
StringBuilder ss;
ss << " shard query servers: " << servers.size() << "\n";
for ( set<ServerAndQuery>::iterator i = servers.begin(); i!=servers.end(); i++ ){
@ -74,6 +74,8 @@ namespace mongo {
assert( cursor );
log(5) << " cursor type: " << cursor->type() << endl;
ShardedClientCursor * cc = new ShardedClientCursor( q , cursor );
if ( ! cc->sendNextBatch( r ) ){
delete( cursor );