diff options
Diffstat (limited to 's/commands_public.cpp')
-rw-r--r-- | s/commands_public.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/s/commands_public.cpp b/s/commands_public.cpp index f29205b2326..44c910b136c 100644 --- a/s/commands_public.cpp +++ b/s/commands_public.cpp @@ -375,9 +375,13 @@ namespace mongo { long long total = 0; map<string,long long> shardCounts; + int numTries = 0; + bool hadToBreak = false; ChunkManagerPtr cm = conf->getChunkManager( fullns ); - while ( true ) { + while ( numTries < 5 ) { + numTries++; + if ( ! cm ) { // probably unsharded now return run( dbName , cmdObj , errmsg , result , l ); @@ -387,7 +391,7 @@ namespace mongo { cm->getShardsForQuery( shards , filter ); assert( shards.size() ); - bool hadToBreak = false; + hadToBreak = false; for (set<Shard>::iterator it=shards.begin(), end=shards.end(); it != end; ++it) { ShardConnection conn(*it, fullns); @@ -428,6 +432,10 @@ namespace mongo { if ( ! hadToBreak ) break; } + if (hadToBreak) { + errmsg = "Tried 5 times without success to get count for " + fullns + " from all shards"; + return false; + } total = applySkipLimit( total , cmdObj ); result.appendNumber( "n" , total ); |