BewareMyPower commented on issue #116:
URL: 
https://github.com/apache/pulsar-client-python/issues/116#issuecomment-1537049348

   From the threads info, the root cause is still related to the 
`NegativeAcksTracker`. Here are the simplified threads info:
   
   ```
   Thread 2 stuck at:
     acquiring lock in NegativeAcksTracker::add
   
   Thread 14 stuck at:
     acquiring GIL in LoggerWrapper::log
       ConsumerImpl::redeliverMessages
         NegativeAcksTracker::handleTimer
   
   ----
   
   Thread 6 stuck at:
     acquiring GIL in LoggerWrapper::log
       ClientConnection::handleIncomingCommand
   
   Thread 8 stuck at:
     acquiring GIL in LoggerWrapper::log
       ClientConnection::getConnectionAsync
         PartitionedConsumerImpl::getPartitionMetadata
   
   Thread 15 stuck at:
     acquiring GIL in LoggerWrapper::LoggerWrapper
       ConsumerStatsImpl::flushAndReset
   
   Thread 13 stuck at
     acquiring GIL in LoggerWrapper::log
       ClientConnection::handleIncomingCommand
   ```
   
   Nearly all threads except thread 2 are stuck at acquiring GIL in 
`LoggerWrapper`'s methods. It means the GIL was hold by another thread, which 
is likely thread 2 because it calls `negative_acknowledge`. However, thread 2 
is also stuck because the lock in `NegativeAcksTracker` is hold by thread 14.
   
   In conclusion:
   - Thread 2 holds the GIL, then tries to acquire `NegativeAcksTracker#mutex_`
   - Thread 14 holds the `NegativeAcksTracker#mutex_`, then tries to acquire 
the GIL
   
   Since the GIL won't be released, all threads that try to acquire the GIL 
will be stuck. It will block nearly all threads when the Python logger is 
customized because all methods of `LoggerWrapper` requires the GIL.
   
   I'm going to check the code in further progress and see how could we fix 
this deadlock.
   
   (BTW, this threads info is strange that I see `CaptivePythonObjectMixin` in 
it. But this class was first introduced in 3.0.0)


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to