Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4137

Client shutdown does not emit ServerClosedEvents

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Background & Motivation

      libmongoc does not call a callback registered with mongoc_apm_set_server_closed_cb when a mongoc_client_t or mongoc_client_pool_t is destroyed.

      This appears to contradict the SDAM Monitoring specification's definition os ServerClosedEvent

      ServerClosedEvent Published when the server monitor’s connection is closed and the server is shutdown.

      libmongoc does emit the ServerClosedEvent in the following situations:
      1. A server is removed from the topology description when processing a server description. This follows the SDAM topology type table. This occurs in _mongoc_topology_description_remove_server.
      2. A mongoc_client_t or mongoc_client_pool_t connected to a load balanced topology is being destroyed. This occurs in _mongoc_topology_description_monitor_closed.

      This can be observed with example-sdam-monitoring.

      ./cmake-build/src/libmongoc/example-sdam-monitoring "mongodb://localhost:27017"
      
      Events:
         server changed: 1
         server opening: 1
         server closed: 0
         topology changed: 2
         topology opening: 1
         topology closed: 1
         heartbeat started: 1
         heartbeat succeeded: 1
         heartbeat failed: 0
      

      Scope

      Use _mongoc_topology_description_monitor_server_closed to emit a ServerClosedEvent for each server being monitored when a mongoc_client_t or mongoc_client_pool_t is being destroyed.

      Add tests to ensure server closed events are emitted. This may not be necessary if DRIVERS-1087 is complete before this ticket. SPEC-1280 proposes adding specification tests to test this behavior.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: