feat: add interruptInUseConnections client option#4961
Open
italojs wants to merge 1 commit into
Open
Conversation
When the SDAM monitor heartbeat times out, the driver clears the connection pool with interruptInUseConnections=true, rejecting in-flight operations with a PoolClearedOnNetworkError. For operations the driver does not retry (notably tailable getMore), this surfaces as an unrecoverable error after a transient blip such as a host being suspended/resumed (e.g. a laptop sleeping). Add a boolean interruptInUseConnections MongoClientOptions (default true, preserving the current SDAM spec behaviour). When set to false, a monitor network timeout still clears the pool (ResetPool) but does not interrupt in-use connections, so such in-flight operations are left untouched and resume once the server is reachable again. Refs: meteor/meteor#13108
Contributor
Author
Reproduction & verification (PoC)A standalone, deterministic before/after proof of concept — plain Node + this driver + MongoDB in Docker, no Meteor:
Same build in both runs; only the option changes. Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a boolean
interruptInUseConnectionsMongoClientOptions(defaulttrue, preserving the current SDAM spec behaviour).When the SDAM monitor heartbeat times out, the driver clears the connection pool with
interruptInUseConnections: true, which rejects in-flight operations with aPoolClearedOnNetworkError. For operations the driver does not retry — notably tailablegetMore— this surfaces as an unrecoverable error after a transient blip such as a host being suspended/resumed (for example a laptop sleeping).Setting
interruptInUseConnections: falsemakes a monitor network timeout still clear the pool (ResetPool) but not interrupt in-use connections, so those in-flight operations are left untouched and resume once the server is reachable again. The pool is still cleared and the driver reconnects as usual.Motivation
There is currently no supported way to opt out of the in-use connection interruption introduced with the
interruptInUseConnectionsSDAM behaviour. This is the root of a long-standing "idle crash" reported downstream in Meteor (meteor/meteor#13108): when a laptop sleeps, the localmongodis frozen, the monitor times out, and the oplog tail'sgetMore— which the driver never retries — rejects withPoolClearedOnNetworkErrorand crashes the process. The same applies to any long-lived/non-retried operation across a transient network blip.I don't have a NODE Jira ticket for this, happy to reword the commit/title with one if a maintainer assigns it.