-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
Following investigation into DRIVERS-2677, it was discovered that the Node driver measures heartbeat duration incorrectly. On initial creation of a monitoring connection, the heartbeat duration calculation includes the time taken to establish the initial TCP connection as well as the time to send a hello/legacy hello and receive a response from the server. This goes against the definition of the heartbeat duration for ServerHeartbeatSucceeded and ServerHeartbeatFailed events as laid out in the SDAM Events API spec.
From local testing, when connecting to an Atlas cluster with the driver, this consistently results in initial heartbeat durations of ~200ms with median durations of 21ms.
Use Case
As a Driver Engineer
I want to measure heartbeat duration from just before the call to hello/legacy hello
So that heartbeat duration is measured accurately.
User Impact
- None
Dependencies
- upstream and/or downstream requirements and timelines to bear in mind
Unknowns
- Will this clash with CSOT implementation?
Acceptance Criteria
Implementation Requirements
- Update checkServer in src/sdam/monitor.ts to properly record duration of heartbeat as the time between sending a hello and receiving a response in all cases
Testing Requirements
- Write unit tests that assert that the first heartbeat has a duration that is more consistent with subsequent heartbeats.
- Using mock local server so that it is integration-like
Documentation Requirements
- None
Follow Up Requirements
- additional tickets to file, required releases, etc
- is related to
-
NODE-5825 Add minRoundTripTime field and calculation to Monitor
- Closed
- related to
-
DRIVERS-2677 Clarify whether heartbeat started event should be emitted before connection establishment in ServerMonitor
- Implementing