Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-2023

Allow observation of TopologyClosedEvent

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.13.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Several factors may prevent TopologyClosedEvents from being observed.

      In php_phongo_pclient_destroy, which is used to free both persistent and non-persistent clients belonging to the same process, we clear the APM callbacks on a client before calling mongoc_client_destroy. As noted in the comments, this has no effect for global, persistent clients since the subscribers would already have been freed by the time those clients are destroyed; however, it would prevent events being dispatched for non-persistent (i.e. request-scoped) clients. The reasoning for this logic is to avoid dispatching command monitoring events issued during client destruction (e.g. killing cursors or sessions) and references PHPC-1666; however, it's possible that this actually depends on PHPC-1741 (removing the Manager reference entirely from command monitoring event objects).

      In php_phongo_manager_free_object, php_phongo_manager_unregister is called before php_phongo_client_unregister. The Manager registry was introduced in PHPC-1645 with non-persistent clients. When a Manager is removed from the registry, phongo_apm_get_subscribers_to_notify will no longer be able to find its subscribers when invoked through the topology_closed callback. This is despite the fact that the Manager's subscribers aren't actually freed until later in php_phongo_manager_free_object. Swapping the order of php_phongo_manager_unregister and php_phongo_client_unregister would address this; however, we'll need to ensure that doesn't cause some other conflict (e.g. null deference attempting to fetch a Manager for a dispatched event).

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: