Hi,
we have a cluster containing three replica sets. There are three mongos instances with the application doing inserts. There is one more mongos instance which is only doing some aggregation and exporting every night. Furthermore on this instance there is a little PHP script which creates a new collection for the next day and enables sharding for this collection.
The script is really super simple, its just
-------------8<-------------
$connection = new MongoClient( "mongodb://somehost:someport" );
$connection->selectDB("admin")->command(array('shardcollection'=>'tracker.view_'.date('Ymd'),'key'=>array('_id'=>1)));
-------------8<-------------
wrapped by a try-catch block.
However, if I check the sharding status next morning the collection is not sharded.
I did some tests the last few days:
- executed db.adminCommand({flushRouterConfig: 1}) on one application mongos. The result was, the unsharded collection gets immediately sharded.
- executed db.adminCommand( {shardCollection: "tracker.view_20130222", key: {"_id": 1}} ) on the aggregation mongos. The result here was also the collections gets immediately sharded and it returns "{ "ok" : 0, "errmsg" : "already sharded" }"
So to me it seems that the information collection_xyz has to be sharded didn't made it to either the config server or the other mongos if the command is executed via PHP.
We use mongo php driver version 1.3.4 and mongos version 2.0.4
Does anybody have some thoughts about this? Thanks in advance!