ServerHeartbeatSucceededEvent is not fired for initial POLL monitoring

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Minor - P4
    • 5.7.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Java Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      While working on https://github.com/mongodb/mongo-java-driver/pull/1854 I've noticed that the test fails with:

      Timed out waiting for 1 ServerHeartbeatSucceededEvent events
      

      which indicates that ServerHeartbeatSucceededEvent was not triggered for the initial connection.

      We need to ensure consistent event notifications. Applications and monitoring tools that listen for ServerHeartbeatSucceededEvent expect to receive it for every successful health check, including the very first one right after the connection is established. Without that initial heartbeat, we end up with a window where:

      • The server state transitions from UNKNOWN to a known state
      • But no ServerHeartbeatSucceededEvent is emitted

      Listeners therefore, miss the first successful health check notification

      This behavior is only required in POLL mode (!shouldStreamResponses). In streaming mode, the connection stays open and continuously receives updates, so the standard event flow already ensures that heartbeats (and their corresponding events) are emitted as expected.

            Assignee:
            Nabil Hachicha
            Reporter:
            Nabil Hachicha
            Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: