Replica set - Replication timeout - Write Exception

772 views
Skip to first unread message

David O'Shea

unread,
Feb 5, 2018, 11:23:48 AM2/5/18
to mongodb-user
Currently experiencing intermittent occurrences of the following error:

- MongoDB.Driver.MongoWriteException A write operation resulted in an error. waiting for replication timed out  at MongoDB.Driver.MongoCollectionBase

Context
- Recently upgraded from MongoDB 3.2 to MongoDB 3.4
- We have seen the same error with MongoDB 3.2 but it appears to occur more frequently with MongoDB 3.4
- 3 servers making up the replica set, all same spec
- Application connection string reads
    mongodb://server1:27017,server2:27017,server3:27017/?connect=replicaset&replicaSet=replicasetname&w=majority&wtimeoutMS=2000

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). 

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?
Typically what (if any) value are people using for wTimeOutMS within connection strings? 
At what timespan would one consider replication lag to be worth investigating?

Thanks
David.

Wan Bachtiar

unread,
Mar 13, 2018, 1:52:36 AM3/13/18
to mongodb-user

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.

Reply all
Reply to author
Forward
0 new messages