Skip to content

Commit

Permalink
Reproduce error with serverSelectionTryOnce=false
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrokeil committed Mar 20, 2017
1 parent 1d7a37a commit ae01c94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

try {
$clientPrimaryPreferred = new \MongoDB\Client(
'mongodb://node0.mongodb.local:27017,node1.mongodb.local:27017,node2.mongodb.local:27017?replicaSet=cluster&connectTimeoutMS=2000&readPreference=primaryPreferred',
'mongodb://node0.mongodb.local:27017,node1.mongodb.local:27017,node2.mongodb.local:27017?replicaSet=cluster&connectTimeoutMS=2000&readPreference=primaryPreferred&serverSelectionTryOnce=false',
[],
//force usage of assoc instead of stdClass objects when returning data from mongodb
['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']]
);

$clientSecondaryPreferred = new \MongoDB\Client(
'mongodb://node0.mongodb.local:27017,node1.mongodb.local:27017,node2.mongodb.local:27017?replicaSet=cluster&connectTimeoutMS=2000&readPreference=secondaryPreferred',
'mongodb://node0.mongodb.local:27017,node1.mongodb.local:27017,node2.mongodb.local:27017?replicaSet=cluster&connectTimeoutMS=2000&readPreference=secondaryPreferred&serverSelectionTryOnce=false',
[],
//force usage of assoc instead of stdClass objects when returning data from mongodb
['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']]
Expand Down
12 changes: 12 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ docker-compose exec mongodb2 sh status.sh
query
query
query

AFTER_IDLE_TIME=900

echo "${GREEN}Starting after test queries every 5s.${RESET}"

until [ $AFTER_IDLE_TIME -lt 1 ]; do
date
let AFTER_IDLE_TIME-=5
printf "${AFTER_IDLE_TIME} "
query
sleep 5
done

0 comments on commit ae01c94

Please sign in to comment.