Mongo write timeout option


Not sure if this is meteor or the node.js driver - but I can’t get the timeout options for mongo to work as expected.

The scenario is this - I have a secondary database replicaset running on entirely different hardware from the main database - it’s only role is to log user interactions with the server. The idea was that if the entire replicaset went away for any reason, the application would continue working - just without logging interactions. The goal here is to avoid adding anything that could crash the entire application (e.g., the whole database goes away).

I’ve got this working pretty well - the calls to this secondary database are in Meteor.defer blocks, however - today while running a VERY long command on the primary database (resizing a capped collection), the application servers thought the database was unavailable (which it was) and the queries hung…About 30 minutes later, the database comes back - and all of the app servers issued all of the “hung” queries at the same time - which locked up the app :man_facepalming:

I want to ensure that this doesn’t happen again - so I start looking into timeout options for the write:

wtimeout - only works when you specify a majority write concern - and only impacts the time taken to wait for this majority to acknowledge.
w=0 - has no impact on the time the query waits
connectTimeoutMS - only impacts the time it will wait for a new connection - no help if the connection is hung, or in this case writes can’t be accepted due to a global lock
socketTimeoutMS - this is the one I expected to do the trick, it did not. Not only did it not ensure that the write timed out, it also ensured that the socket was killed every 1000ms :man_facepalming: not the desired affect at all.

How can I timeout queries to protect against this?