Note the use of the wTimeOutMS option within the connection string, which we understand is leading the driver to report back failure when the write has not been acknowledged by the replica set within 2000 ms (2 sec).
Hi David,
It’s been a while since you posted this question, have you found a solution yet ?
wtimeout causes write operations to return with an error after the specified limit, even if the required write concern will eventually succeed. When these write operations return, MongoDB does not undo successful data modifications performed before the write concern exceeded the wtimeout time limit.
Are there other server statistics we should be examining around the time of the errors to determine what is preventing MongoDB from completing the writes within the allotted 2 second window?
First check the replication lag of the replica set members. Identify which replica set members are lagging behind (>=2seconds) during peak operation.
Analyse the log files of the replica set members to analyse performance and identify bottlenecks. You can also utilise some MongoDB Reporting Tools to perform the analysis. See also MongoDB monitoring and mtools.
Regards,
Wan.