Skip to content

Commit

Permalink
debugging for shard test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Apr 25, 2011
1 parent fe868a3 commit 03d6d92
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion s/commands_admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,14 @@ namespace mongo {
BSONObjBuilder b;
b.append( "ns" , ns );

BSONArrayBuilder allIndexes;

auto_ptr<DBClientCursor> cursor = conn->query( config->getName() + ".system.indexes" , b.obj() );
while ( cursor->more() ) {
BSONObj idx = cursor->next();

allIndexes.append( idx );

bool idIndex = ! idx["name"].eoo() && idx["name"].String() == "_id_";
bool uniqueIndex = ( ! idx["unique"].eoo() && idx["unique"].trueValue() ) ||
idIndex;
Expand All @@ -458,7 +462,7 @@ namespace mongo {
conn.done();
return false;
}

if( careAboutUnique && hasShardIndex && ! hasUniqueShardIndex ){
errmsg = (string)"can't shard collection " + ns + ", index not unique";
conn.done();
Expand Down Expand Up @@ -487,6 +491,8 @@ namespace mongo {

if ( ! hasShardIndex && ( conn->count( ns ) != 0 ) ) {
errmsg = "please create an index over the sharding key before sharding.";
result.append( "proposedKey" , key );
result.appendArray( "curIndexes" , allIndexes.done() );
conn.done();
return false;
}
Expand Down

0 comments on commit 03d6d92

Please sign in to comment.