heronr opened a new issue #4070: [pulsar-client-cpp] Deadlock when closing the 
pulsar Client
URL: https://github.com/apache/pulsar/issues/4070
 
 
   **Describe the bug**
   There is a consistent deadlock when closing an instance of pulsar::Client if 
there is an active Consumer subscription. This is caused by the ExecutorService 
worker thread attempting to join() itself when a message is received from the 
broker that signals the Consumer is closed. The deadlock is not apparent on 
Unix because in the case of a thread joining itself, pthread_join returns the 
error code EDEADLK and continues execution.
   
   **To Reproduce**
   Create a simple test app that does any action on a Consumer subscription. 
Here is what my test app does...
   1. Create a pulsar::Client instance that connects to a broker with existing 
messages on a topic (e.g. "test_topic").
   2. Subscribe to "test_topic" and seek to earliest message.
   3. receive() and acknowledge() at least one message.
   4. Close the client ( client.close() ).
   5. Deadlock. 
   
   Most likely the only way to confirm this deadlock on Linux is to step into 
the call to worker_.join() within ExecutorService::close() after client.close() 
has been called. Then you will see the EDEADLK error code being returned from 
pthread_join()
   
   **Expected behavior**
   The expectation is that closing the pulsar::Client does not result in a 
deadlocked thread.
   
   **Desktop (please complete the following information):**
   - Ubuntu 18.04
   - Windows 10
   I encountered this on my fork where I made pulsar-client-cpp compile for 
Windows, but it occurs on Ubuntu as well with the caveat that execution 
continues after pthread.join() returns the EDEADLK error thus hiding the 
problem. 
   
   **Additional context**
   I have attached a text file with the callstack observed. 
   
[DeadlockStack.txt](https://github.com/apache/pulsar/files/3092736/DeadlockStack.txt)
   
   

----------------------------------------------------------------
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

Reply via email to