Repository navigation
Conversation
RTTPinger.measureRoundTripTime returned after a connect failure or a hello failure and never armed the next sample. latestRtt then stayed at the last successful value while streaming heartbeats and client-side operation timeouts kept using it. The hello monitor itself continued. Schedule the next sample after heartbeatFrequencyMS on either failure. Do not store the failed duration as latestRtt. connect() already destroys the socket it failed to open. The command-failure path still destroys the dedicated connection before the next sample opens another.
Contributor
This branch has not been deployed
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.
Description
Summary of Changes
RTTPingerschedules another round-trip sample afterconnectfails or the dedicatedhellofails. A failed attempt does not replacelatestRtt.Notes for Reviewers
connect()already destroys the socket when the handshake fails, so the connect-failure path only clears the pinger's connection reference and arms the next timer. The command-failure path still destroys the dedicated connection, which is whattest/integration/connection-monitoring-and-pooling/rtt_pinger.test.tsasserts. That test was not run here (it needs a MongoDB deployment). The new unit tests cover both failure paths withmongodb-mockand a refused local port.Jira: NODE-7985
What is the motivation for this change?
One dropped RTT socket made server selection and operation timeouts keep a stale round-trip time for as long as the server kept streaming hellos.
For bug fixes
Current (incorrect) behavior:
After the dedicated RTT connection fails to connect, or its hello fails, no further RTT sample is scheduled.
latestRttstays at the last success. The streaming hello monitor is unaffected.Expected behavior:
The pinger destroys the failed socket, leaves
latestRttunchanged, and measures again afterheartbeatFrequencyMS. A later success updateslatestRtt.How to reproduce:
Create an
RTTPingeragainst a mock that accepts the first hello and destroys the socket on the second. Before this change the pinger stops at two hellos. After it, a third hello is sent andlatestRttis still the value captured from the successful sample at the moment the failed command rejects.Unit coverage:
test/unit/sdam/rtt_pinger.test.ts.Affected versions:
Present on main. Requires a server that advertises
topologyVersionso the driver creates anRTTPinger(streaming monitoring, MongoDB 4.4+). The bug is in the driver, not in a particular server version beyond that.Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript