Priority: Major - P3
Affects Version/s: 3.6.1
Fix Version/s: None
Steps To Reproduce:
Please see the description and the doc here: https://github.com/rystsov/perseus/tree/master/mongodb
I was testing how a 3-nodes cluster of MongoDB behaves (from a client perspective) when one of the nodes is isolated from the cluster and observed an anomaly.
TL;DR: When a node is isolated, all clients hang for almost two minutes (unexpected behaviour, too long downtime). A client running on the isolated node continues being down (expected behaviour), but the clients on healthy nodes become unexpectedly slow (RPS drop to less than one operation per second from 282 before the isolation).
OS: Ubuntu 17.10
MongoDB driver: NPM: "mongodb": 3.0.1
Three nodes (mongo1, mongo2, mongo3) form a MongoDB cluster running mongod in a single replica set. Besides mongod, each node has a NodeJS app which:
- in a loop reads a value from the cluster, increments it and writes back
- exposes API to fetch number of successful and failed iterations
Also there is a fourth node (client1) which fetches the stat and dumps it every second in the following format:
The first column is the number of passed seconds since the beginning of the experiment; the next three columns contain counter of successful iterations of the clients located on each node per last second, following three columns are counters of errors and the last one is time.
Client is a NodeJS app using the following connection URL: mongodb://mongo1,mongo2,mongo3/?replicaSet=rs0&autoReconnect=false&socketTimeoutMS=10000&connectTimeoutMS=10000.
Each write operation has writeConcern "majority" while each read operation has readConcern "linearizable".
When a client runs into a problem it closes the current connection and opens a new one.
Each client uses a different key to avoid collisions.
The network isolation is simulated with iptables:
During the isolation, the traffic is blocked between mongo1 and (mongo2 & mongo3), but client1 can see all nodes.
Let's take a look on the logs of the aggregating client (client1.log):
As you can see, clients on mongo1, mongo2, mongo3 stopped doing progress after the isolation. 117 seconds later mongo2 and mongo3 "recovered" but they became very slow.
When the connection was restored it took 38s until mongo2, mongo3 recovered to their previous pace, but mongo1 remained silent (unexpected behaviour).
Please see the attached "slow-full.tar.gz" archive for logs.
Log of the aggregating client. Its format was described above.
Log of the actual client. In happy case it looks like:
Each successful iteration is represented by a sequence of lines (reading, creating|updating, ok). During a connection you'll see "connecting" and "ok" records. "stat" record corresponds to the fetch request from the aggregating client and helps to understand how long the previous operation hangs.
If there are errors during the execution, then they also are dumped into this log like:
- "MongoNetworkError: connection 0 to mongo1:27017 timed out"
- "MongoNetworkError: failed to connect to server mongo3:27017 on first connect"
Log of the mongod processes.
Why do I think it's more a bug rather than a misconfiguration?
The bug isn't always reproducible: sometimes the pace of mongo2 and mongo3 doesn't degrade and when the connection is restored the mongo1's client starts working. See the attached "good-full.tar.gz".
I hope this report will help you!