Permalink
Browse files

split chunk maybe the first time a sharded command hit mongod

  • Loading branch information...
Alberto Lerner
Alberto Lerner committed Oct 25, 2010
1 parent be3ca8e commit 7e074d00e4b049cf4075fee05365f2c5d0550bf9
Showing with 14 additions and 1 deletion.
  1. +2 −1 s/chunk.cpp
  2. +12 −0 s/d_split.cpp
View
@@ -298,7 +298,8 @@ namespace mongo {
cmd.append( "min" , getMin() );
cmd.append( "max" , getMax() );
cmd.append( "splitKeys" , m );
- cmd.append( "shardId", genID() );
+ cmd.append( "shardId" , genID() );
+ cmd.append( "configdb" , configServer.modelServer() );
BSONObj cmdObj = cmd.obj();
if ( ! conn->runCommand( "admin" , cmdObj , result )) {
View
@@ -431,6 +431,18 @@ namespace mongo {
return false;
}
+ // It is possible that this is the first sharded command this mongod is asked to perform. If so,
+ // start sharding apparatus.
+ if ( ! shardingState.enabled() ){
+ if ( cmdObj["configdb"].type() != String ){
+ errmsg = "sharding not enabled";
+ return false;
+ }
+ string configdb = cmdObj["configdb"].String();
+ shardingState.enable( configdb );
+ configServer.init( configdb );
+ }
+
//
// 2. lock the collection's metadata and get highest version for the current shard
//

0 comments on commit 7e074d0

Please sign in to comment.