-
-
Save leozc/6126556 to your computer and use it in GitHub Desktop.
| <? | |
| // simple mongoclient dumpper | |
| $a=getMongo(); | |
| $b=getMongo(); | |
| var_dump($a->getConnectionss()); | |
| print("===================================SECOND MONGO CONN REQUEST ===================================\n"); | |
| var_dump($b->getConnectionss()); | |
| function getMongo(){//{{{ | |
| $mongo = new MongoClient(MG_HOST, array( | |
| 'replicaSet' => MG_REPLICASET, | |
| 'password'=>MG_PWD, | |
| 'username'=>MG_USER, | |
| 'db'=>MG_DB, | |
| 'journal' => true, | |
| "readPreference"=> MongoClient::RP_SECONDARY_PREFERRED | |
| ) | |
| ); | |
| $mgdb = $mongo->{MG_DB}; | |
| return $mongo; | |
| } | |
| ?> |
It seems, alone with 2 connections (one to primary and one to secondary), there are TWO topology connections built, one for primary and one to secondary) - seems additional overheads for me.
Particularly this worries me:
WARN: discover_topology: ismaster worked, but we need to remove the seed host's connection ....
[31-Jul-2013 22:32:07 UTC] PHP Notice: CON INFO: ismaster: last ran at 1375309927 in /var/app/current/testmongo.php on line 47
[31-Jul-2013 22:32:07 UTC] PHP Notice: CON WARN: discover_topology: ismaster worked, but we need to remove the seed host's connection in /var/app/current/testmongo.php on line 47
[31-Jul-2013 22:32:07 UTC] PHP Notice: CON FINE: mongo_connection_destroy: Destroying connection object for
[31-Jul-2013 22:32:07 UTC] PHP Notice: CON FINE: mongo_connection_destroy: Closing socket for
[31-Jul-2013 22:32:07 UTC] PHP Notice: CON FINE: discover_topology: ismaster worked in /var/app/current/testmongo.php on line 47
@leozc: Please format the var_dump output with monospace formatting (three ` characters on a line before and after will do it). It's a bit hard to read in the current state.
Re:jmlkola.
@leozc: The error you're seeing is because the connection string hostname doesn't match what the servers themselves identify as. Take a look at mongo_connection_ismaster and look for the retval = 3 case.
Very nice hint! It ends up it is a domain name alias problem, let me investigate further...
Take a look at mongo_connection_ismaster and look for the retval = 3 case. helps
Each connection has Two Servers, 1 to Primary and 1 To Secondary.
ALl connections have ["pid"]=> int(32492) ( I guess it is process Id)