You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pulsar client with custom logger may not terminate gracefully when a producer is created #256
When providing a custom logger to the Pulsar client and creating a producer, intermittent terminations occur with the following error:
terminate called without an active exception
Aborted (core dumped)
This doesn't happen consistently; I'd estimate it occurs in about 1 out of 20 runs. The other executions complete gracefully as expected. As the setup here is almost exactly as in #194, I've tried adding the del statements suggested there, but that hasn't resolved the issue for me.
I added a log after client.close() and enabled debug level logs:
print('client is closed')
delproducerdelclient
DEBUG:pulsarDummyLogger:ioExecutorProvider_ is closed
DEBUG:pulsarDummyLogger:listenerExecutorProvider_ is closed
DEBUG:pulsarDummyLogger:partitionListenerExecutorProvider_ is closed
client is closed
DEBUG:pulsarDummyLogger:[persistent://public/default/A, standalone-0-631] ~ProducerImpl
INFO:pulsarDummyLogger:Producer - [persistent://public/default/A, standalone-0-631] , [batching = off]
terminate called without an active exception
The most possible reason is that the shutdown thread didn't exit when the Python interpreter exited. It might need a fix from the C++ client side.
While I might need more time to figure out a fix and verify if it works, I thought of a more tricky workaround and found it worked.
client.close()
time.sleep(0.01) # The trick is here that wait for some time until the shutdown thread is finisheddelproducer# This line is actually not necessarydelclient
Thanks for looking into this and suggesting a temporary solution! Your time and effort are greatly appreciated.
Yes, adding the timeout does resolve the immediate issue. Thank you!
For my specific use case, I'd prefer to stick with the default Pulsar logger at the ERROR level. This would keep logs minimal, appearing only in rare error scenarios, rather than implementing a timeout each time I close the client.
I hope you'll be able to address the root cause of this issue soon.
Activity
BewareMyPower commentedon May 22, 2025
I cannot reproduce it on macOS or Ubuntu 22.04 docker container (
localhostis changed tohost.docker.internal).BewareMyPower commentedon May 22, 2025
Oh I can reproduced it with another round of tests with the INFO log enabled:
Let me assign it to myself
BewareMyPower commentedon May 22, 2025
It seems that there is a rare chance that the shutdown thread failed to exit.
From the logs above from GDB, LWP 6877, which is the shutdown thread introduced in apache/pulsar#15316, didn't exit when the exception was thrown.
std::thread shutdownTask{[this, self, callback] { shutdown(); // ...I added a log after
client.close()and enabled debug level logs:The most possible reason is that the shutdown thread didn't exit when the Python interpreter exited. It might need a fix from the C++ client side.
While I might need more time to figure out a fix and verify if it works, I thought of a more tricky workaround and found it worked.
Could you verify it?
tzvi-shir-vaknin commentedon May 22, 2025
Thanks for looking into this and suggesting a temporary solution! Your time and effort are greatly appreciated.
Yes, adding the timeout does resolve the immediate issue. Thank you!
For my specific use case, I'd prefer to stick with the default Pulsar logger at the ERROR level. This would keep logs minimal, appearing only in rare error scenarios, rather than implementing a timeout each time I close the client.
I hope you'll be able to address the root cause of this issue soon.
Thanks again!