Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6831

RTTSampler records samples only when heartbeats finish in streaming mode

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: SDAM
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Use Case

      The monitor currently captures rtt samples with the following code:

          // NOTE: here we use the latestRtt as this measurement corresponds with the value
          // obtained for this successful heartbeat, if there is no latestRtt, then we calculate the
          // duration
          const duration =
            isAwaitable && monitor.rttPinger
              ? (monitor.rttPinger.latestRtt ?? calculateDurationInMs(start))
              : calculateDurationInMs(start);
      
          monitor.addRttSample(duration);
      

      This code executes on every heartbeat succeeded event.

      (when using the streaming monitoring protocol, `isAwaitable` is true and `rttPinger` exists on the monitor).

      Notice two things when the streaming protocol is set:

      1. The duration of the heartbeat event is set to the last recorded rtt pinging event
      2. the monitor records the sample unconditionally as an rtt sample

      This means rtt pinging events aren't recorded unless heartbeat events finish. And conversely, if an awaitable, exhaustAllowed hello resulted in multiple heartbeat events in less than `heartbeatFrequencyMS`, we'd record multiple rtt samples from the same rtt measurement.

      Instead, when the streaming protocol is enabled, we should only record rtt samples from round trip measurements on the RTTPinger.

      User Experience

      This bug likely has little impact on users because in practice because the rttpinger's ping interval and the frequency of streaming hellos should be roughly aligned (rttpingers poll every heartbeatFrequencyMS, awaitable hellos wait for heartbeatFrequencyMS). In circumstances where multiple heartbeat events are recorded in less than heartbeatFrequencyMS, this results in multiple recorded for the same rtt pinger value, skewing the average and min rtt measurements towards the most recent sample for a period of time.

      Dependencies

      n/a

      Risks/Unknowns

      n/a

      Acceptance Criteria

      Implementation Requirements

      • when streaming is enabled
        • Do not record rtt samples after heartbeats succeed.
        • Record rtt samples for each successful rtt measurement.

      Testing Requirements

      • I'm not sure the best way to test this.

      Documentation Requirements

      n/a

      Follow Up Requirements

      n/a

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              None
              None
              None
              None