mongodb/mongo-php-driver — pull request #302 by bjori (2013-01-30 01:20:29+00:00)
Title: Fixed PHP-686: Constant reconnect attempts to a server that is down

This is because on every single 'new MongoClient' we would do a full
topology discovery and attempt to connect to every single server we
could find - even though we were previously fully aware of the fact the
server was down.
This may have seemed like a good idea, we would quickly discover when
a server became available again..

However, if the machine is completely off we have to wait until the
connect() times out. Again. And Again. And Again, on every 'new
MongoClient'.
In practice that means all requests coming into the application will
have to wait 1second (default) times down servers, which ofcourse is
unacceptable.

Now rather then discarding of the failed connection we keep it around so
we can differenciate betewen changes in the topology (which we need to
add) vs down servers.
We will attempt to reconnect to the server when we hit the ping/ismaster
interval.

This has the added benefit of MongoClient->getConnections() will now
actually list the server, even when down, reducing the "where is the
rest of my replicaset" wtf - but we need to add a new "health" field to
the results.

The only down side is if authentication fails (i.e. invalid credentials)
we won't try (the same credentials) again until ping/ismaster interval
has been hit, which throws the exception "No candidates servers found"
vs "Authentication failed.." for the second connect call per-process.