Php – Why mongo pecl module looses its connection after Primary stepDown

mongodbpeclPHPsharding

I run an Apache 2.2.22-13 with pecl module "mongo 1.4.4". It connects to a MongoDB 2.4.6 sharded cluster.

When a stepDown occurs, the mongo module seems to stay on the mongod node which was the primary and says: "PHP Fatal error: Uncaught exception 'MongoCursorException' with message 'node1.mongodb.cluster:27017: Remote server has closed the connection' …

To establish the connection, I tried the 2 following ways:

$m = new MongoClient('mongodb://mongod0.mongodb.cluster, mongod1.mongodb.cluster, mongod2.mongodb.cluster, mongod3.mongodb.cluster', array("replicaSet" => "myrs"));

and

$m = new MongoClient('mongodb://mongos.mongodb.cluster', array("replicaSet" => "myrs"));

After a stepDown, the two ways give the same error message.

With the first connection string, restarting Apache is enough to get things back on rails.
With the last one, restarting doesn't: I don't get any error message anymore but the data that should come from MongoDB is still missing.

Thanks in advance,

Greg.

Best Answer

I upgraded the mongo pecl module from 1.4.5 to 1.5.8. This problem is fixed.

Related Topic