heronr commented on issue #6277: [Issue 4070][pulsar-client-cpp] Fix for possible deadlock when closing Pulsar client URL: https://github.com/apache/pulsar/pull/6277#issuecomment-585081103 Agreed on your assessment. I tracked one instance of a non-joined thread to the HTTPLookupService owning the ExecutorServiceProvider that it posts its own work onto. Now the provider it uses is owned by the ClientImpl, but this just exposed a different non-joined thread caused by the ClientImpl itself being destroyed on the ExecutorService worker thread. [Here is the callstack](https://gist.github.com/heronr/ace7f608077441effffa52830ab1f877) Ultimately because shared_ptrs are being used to manage the lifetime of objects that then post work to ExecutorServices owned by those same objects, we can encounter a non-joinable thread since there is not fine control over when the ref count goes to 0. If we can designate the pulsar::Client as non-copyable then its destructor can force a shutdown() on the ClientImpl and ensure that all outstanding worker threads are joined at that point as a result. The latest exception that I linked stems from the fact that if a pulsar::Client is destructed without first calling shutdown, any outstanding work on an ExecutorService thread will likely result in the destruction of the ClientImpl on that thread and make it impossible to join.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
