Skip to content

Commit

Permalink
Merge pull request #1 from sandrokeil/feature/update-to-latest-versions
Browse files Browse the repository at this point in the history
Update to latest versions
  • Loading branch information
sandrokeil authored Mar 22, 2018
2 parents ae01c94 + c702b27 commit 8528788
Show file tree
Hide file tree
Showing 9 changed files with 741 additions and 748 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# MongoDB Replica Issue
This repo tries to reproduce the [Intermittent error: MongoConnectionException:No suitable servers found (`serverselectiontryonce` set): Server closed connection. calling ismaster on 'x.x.x.x:27017'](https://github.com/mongodb/mongo-php-driver/issues/532)

I can reproduce the error with this setup. You find the logs of a test run in [log.txt](log.txt) file.
> This is now fixed with MongoDB PHP Driver 1.4.2 and MongoDB PHP Library 1.3.0 with PHP 7.2.3 and Alpine 3.7!
Also take a look at the [`php.txt`](php.txt). The test has finished at `Do 2. Mär 12:06:53 CET 2017` and now look at the
last lines of `php.txt` from `02-Mar-2017 11:08:49`. There are multiple success requests and the sometimes the `not master`
error occurs. The `index.php` writes and reads from MongoDB. Simply reload the page multiple times after the test has finished.
There error still exists.
~~I can reproduce the error with this setup. You find the logs of a test run in [log.txt](log.txt) file.~~

Why are some requests are successfully and some failed? I guess it's a PHP-FPM static child caching (or even opcache) issue.

Expand All @@ -19,11 +16,11 @@ and [Docker Compose >= 1.11](https://docs.docker.com/compose/install/).
Install now Composer dependencies with

```
$ docker run --rm -it --volume $(pwd):/app prooph/composer:7.1 install
$ docker run --rm -it --volume $(pwd):/app prooph/composer:7.2 install
```

## Run test
The [`index.php`](public/index.php) uses two different MongoDB connections with `connectTimeoutMS=2000`.
The [`index.php`](public/index.php) uses two different MongoDB connections.

* One with `readPreference=primaryPreferred` for inserts
* Second with `readPreference=secondaryPreferred` for reads
Expand All @@ -44,7 +41,7 @@ You see the output and it is also written to the `log.txt` file. Search in the l

You can also browse the website [http://localhost:8080/](http://localhost:8080/).

If the test has finished reload this page some times to see the `MongoConnectionException`.
~~If the test has finished reload this page some times to see the `MongoConnectionException`.~~

## Check status manually
To manually check MongoDB Replica Status use one of
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"mongodb/mongodb": "^1.1"
"mongodb/mongodb": "^1.3"
}
}
33 changes: 20 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
image: prooph/nginx:www
ports:
- 8080:80
- 443:443

php:
build: ./env/docker/php
Expand Down
2 changes: 1 addition & 1 deletion env/docker/mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mongo:3.4.2
FROM mongo:3.6.3

COPY mongod.conf /etc
COPY init.sh /
Expand Down
4 changes: 2 additions & 2 deletions env/docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM php:7.1.2-fpm-alpine
FROM php:7.2.3-fpm-alpine3.7

ENV PHP_MONGO_VERSION 1.2.5
ENV PHP_MONGO_VERSION 1.4.2

# persistent / runtime deps
ENV PHPIZE_DEPS \
Expand Down
Loading

0 comments on commit 8528788

Please sign in to comment.