summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-07-22 10:04:17 -0400
committerEliot Horowitz <eliot@10gen.com>2010-07-22 10:04:17 -0400
commit364bad304eacae81874fbd607b0ec3036f9b4118 (patch)
treeb98642ad82f9f3c85b6d8250e8861ce92389c637
parentdf2a72efff66cda640403924d6126e7da0ca852b (diff)
downloadmongo-364bad304eacae81874fbd607b0ec3036f9b4118.tar.gz
make indexe differences warning in stats
-rw-r--r--jstests/sharding/key_many.js1
-rw-r--r--s/commands_public.cpp24
2 files changed, 21 insertions, 4 deletions
diff --git a/jstests/sharding/key_many.js b/jstests/sharding/key_many.js
index 21f37b7f490..1e0ba9d9928 100644
--- a/jstests/sharding/key_many.js
+++ b/jstests/sharding/key_many.js
@@ -115,6 +115,7 @@ for ( var i=0; i<types.length; i++ ){
assert.eq( 4 , c.find({$nor:[makeObjectDotted(curT.values[2]), makeObjectDotted(curT.values[4])]}).itcount() , curT.name + " $nor itcount()" );
var stats = c.stats();
+ printjson( stats )
assert.eq( 6 , stats.count , curT.name + " total count with stats()" );
var count = 0;
for (shard in stats.shards) count += stats.shards[shard].count;
diff --git a/s/commands_public.cpp b/s/commands_public.cpp
index 41f440544d6..b0c6d885069 100644
--- a/s/commands_public.cpp
+++ b/s/commands_public.cpp
@@ -332,6 +332,7 @@ namespace mongo {
long long size=0;
long long storageSize=0;
int nindexes=0;
+ bool warnedAboutIndexes = false;
for ( set<Shard>::iterator i=servers.begin(); i!=servers.end(); i++ ){
ShardConnection conn( *i , fullns );
BSONObj res;
@@ -345,10 +346,25 @@ namespace mongo {
size += res["size"].numberLong();
storageSize += res["storageSize"].numberLong();
- if (nindexes)
- massert(12595, "nindexes should be the same on all shards!", nindexes == res["nindexes"].numberInt());
- else
- nindexes = res["nindexes"].numberInt();
+ int myIndexes = res["nindexes"].numberInt();
+
+ if ( nindexes == 0 ){
+ nindexes = myIndexes;
+ }
+ else if ( nindexes == myIndexes ){
+ // no-op
+ }
+ else {
+ // hopefully this means we're building an index
+
+ if ( myIndexes > nindexes )
+ nindexes = myIndexes;
+
+ if ( ! warnedAboutIndexes ){
+ result.append( "warning" , "indexes don't all match - ok if ensureIndex is running" );
+ warnedAboutIndexes = true;
+ }
+ }
shardStats.append(i->getName(), res);
}