summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/parallel.cpp11
-rw-r--r--client/parallel.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/client/parallel.cpp b/client/parallel.cpp
index d7975a6849b..df2f3fcfc5b 100644
--- a/client/parallel.cpp
+++ b/client/parallel.cpp
@@ -365,6 +365,7 @@ namespace mongo {
void ParallelSortClusteredCursor::_finishCons() {
_numServers = _servers.size();
+ _lastFrom = 0;
_cursors = 0;
if ( ! _sortKey.isEmpty() && ! _fields.isEmpty() ) {
@@ -693,7 +694,13 @@ namespace mongo {
BSONObj best = BSONObj();
int bestFrom = -1;
- for ( int i=0; i<_numServers; i++) {
+ for( int j = 0; j < _numServers; j++ ){
+
+ // Iterate _numServers times, starting one past the last server we used.
+ // This means we actually start at server #1, not #0, but shouldn't matter
+
+ int i = ( j + _lastFrom + 1 ) % _numServers;
+
if ( ! _cursors[i].more() )
continue;
@@ -714,6 +721,8 @@ namespace mongo {
bestFrom = i;
}
+ _lastFrom = bestFrom;
+
uassert( 10019 , "no more elements" , ! best.isEmpty() );
_cursors[bestFrom].next();
diff --git a/client/parallel.h b/client/parallel.h
index 869bff95a4a..cbf64826596 100644
--- a/client/parallel.h
+++ b/client/parallel.h
@@ -241,6 +241,7 @@ namespace mongo {
virtual void _explain( map< string,list<BSONObj> >& out );
int _numServers;
+ int _lastFrom;
set<ServerAndQuery> _servers;
BSONObj _sortKey;