You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/23 03:55:03 UTC

[GitHub] [pulsar-client-cpp] paladin-dalao opened a new issue, #63: [Bug] create producer and close producer in send callback will dead lock

paladin-dalao opened a new issue, #63:
URL: https://github.com/apache/pulsar-client-cpp/issues/63

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.
   
   
   ### Version
   
   2.10.1
   
   ### Minimal reproduce step
   
   1. create producer
   2. pulsar_producer_send_async
   3. pulsar_send_callback close producer , then thread will dead lock
   
   ### What did you expect to see?
   
   thread dead lock
   
   ```
   #5  0x0000000000b2a296 in PulsarProducer::handleSendCallback (result=pulsar_result_Ok, msgId=0xd0f79a0, ctx=0xd12c810) at source/gse-data/server_data/exporter/pulsar/pulsar_producer.cpp:169
   #6  0x0000000000c2586d in __call<void, pulsar::Result&&, const pulsar::MessageId&, 0ul, 1ul, 2ul, 3ul> (__args=<optimized out>, this=<optimized out>) at /usr/include/c++/4.8.2/functional:1296
   #7  operator()<pulsar::Result, const pulsar::MessageId&, void> (this=<optimized out>) at /usr/include/c++/4.8.2/functional:1355
   #8  std::_Function_handler<void (pulsar::Result, pulsar::MessageId const&), std::_Bind<void (*(std::_Placeholder<1>, std::_Placeholder<2>, void (*)(pulsar_result, _pulsar_message_id*, void*), void*))(pulsar::Result, pulsar::MessageId, void (*)(pulsar_result, _pulsar_message_id*, void*), void*)> >::_M_invoke(std::_Any_data const&, pulsar::Result, pulsar::MessageId const&) (__functor=..., __args#0=<optimized out>, __args#1=...) at /usr/include/c++/4.8.2/functional:2071
   #9  0x0000000000d6b0a9 in operator() (__args#1=..., __args#0=pulsar::ResultOk, this=<optimized out>) at /usr/include/c++/4.8.2/functional:2471
   #10 pulsar::completeSendCallbacks(const std::vector<std::function<void(pulsar::Result, const pulsar::MessageId&)>, std::allocator<std::function<void(pulsar::Result, const pulsar::MessageId&)> > > &, pulsar::Result, const pulsar::MessageId &) (callbacks=std::vector of length 1, capacity 1 = {...}, result=pulsar::ResultOk, id=...) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/MessageAndCallbackBatch.cc:57
   #11 0x0000000000cc1313 in complete (messageId=..., result=pulsar::ResultOk, this=0x7f3f4533dbd0) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/OpSendMsg.h:58
   #12 pulsar::ProducerImpl::ackReceived (this=0xd3f0018, sequenceId=sequenceId@entry=0, rawMessageId=...) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/ProducerImpl.cc:834
   #13 0x0000000000d3af27 in pulsar::ClientConnection::handleIncomingCommand (this=this@entry=0xd3fb000) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/ClientConnection.cc:833
   #14 0x0000000000d413da in pulsar::ClientConnection::processIncomingBuffer (this=this@entry=0xd3fb000) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/ClientConnection.cc:686
   #15 0x0000000000d41ef8 in pulsar::ClientConnection::handleRead (this=0xd3fb000, err=..., bytesTransferred=<optimized out>, minReadSize=4) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/ClientConnection.cc:610
   #16 0x0000000000d30cc8 in _M_call<std::shared_ptr<pulsar::ClientConnection>&, boost::system::error_code&, unsigned long&, unsigned int&> (__ptr=..., this=<optimized out>) at /usr/include/c++/4.8.2/functional:558
   #17 operator()<std::shared_ptr<pulsar::ClientConnection>&, boost::system::error_code&, long unsigned int&, unsigned int&, void> (__object=..., this=<optimized out>) at /usr/include/c++/4.8.2/functional:610
   #18 __call<void, boost::system::error_code&, unsigned long&, 0ul, 1ul, 2ul, 3ul> (__args=<optimized out>, this=<optimized out>) at /usr/include/c++/4.8.2/functional:1296
   #19 operator()<boost::system::error_code&, long unsigned int&, void> (this=<optimized out>) at /usr/include/c++/4.8.2/functional:1355
   #20 operator()<boost::system::error_code, long unsigned int> (arg2=<optimized out>, arg1=..., this=<optimized out>) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/UtilAllocator.h:63
   #21 operator() (this=<optimized out>) at /usr/local/include/boost/asio/detail/bind_handler.hpp:127
   #22 asio_handler_invoke<boost::asio::detail::binder2<AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientConnection::*)(const boost::system::error_code&, long unsigned int, unsigned int)>(std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> >, boost::system::error_code, long unsigned int> > (function=...) at /usr/local/include/boost/asio/handler_invoke_hook.hpp:64
   #23 boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientConnection::*)(const boost::system::error_code&, long unsigned int, unsigned int)>(std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> >, boost::system::error_code, long unsigned int>, AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientConnection::*)(const boost::system::error_code&, long unsigned int, unsigned int)>(std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> > >(boost::asio::detail::binder2<AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientConnection::*)(const boost::system::error_code&, long unsigned int, unsigned int)>(std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> >, boost::system::error_code, long unsigned int> &, AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientCo
 nnection::*)(const boost::system::error_code&, long unsigned int, unsigned int)>(std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> > &) (function=..., context=...) at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:37
   #24 0x0000000000d4c6c8 in boost::asio::detail::reactive_socket_recv_op<boost::asio::mutable_buffers_1, AllocHandler<std::_Bind<std::_Mem_fn<void (pulsar::ClientConnection::*)(boost::system::error_code const&, unsigned long, unsigned int)> (std::shared_ptr<pulsar::ClientConnection>, std::_Placeholder<1>, std::_Placeholder<2>, unsigned int)> > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (owner=0xce020b0, base=<optimized out>) at /usr/local/include/boost/asio/detail/reactive_socket_recv_op.hpp:110
   #25 0x0000000000c7bcdf in complete (bytes_transferred=<optimized out>, ec=..., owner=..., this=0xd0f50e0) at /usr/local/include/boost/asio/detail/task_io_service_operation.hpp:37
   #26 do_run_one (ec=..., this_thread=..., lock=..., this=0xce020b0) at /usr/local/include/boost/asio/detail/impl/task_io_service.ipp:384
   #27 boost::asio::detail::task_io_service::run (this=0xce020b0, ec=...) at /usr/local/include/boost/asio/detail/impl/task_io_service.ipp:153
   #28 0x0000000000c77b2a in run (this=<optimized out>, ec=...) at /usr/local/include/boost/asio/impl/io_service.ipp:66
   #29 pulsar::ExecutorService::__lambda0::operator() (__closure=0xd10efb0) at /data/workspace/third-party-lib/pulsar-2.10.1/pulsar-client-cpp/lib/ExecutorService.cc:43
   #30 0x00007f454943f340 in ?? () from /lib64/libstdc++.so.6
   #31 0x00007f4548f5fea5 in start_thread () from /lib64/libpthread.so.0
   #32 0x00007f454857a9fd in clone () from /lib64/libc.so.6
   ```
   
   ### What did you see instead?
   
   producer close and no dead lock thread 
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
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: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] BewareMyPower closed issue #63: [Bug] create producer and close producer in send callback will dead lock

Posted by GitBox <gi...@apache.org>.
BewareMyPower closed issue #63: [Bug] create producer and close producer in send callback will dead lock
URL: https://github.com/apache/pulsar-client-cpp/issues/63


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] BewareMyPower commented on issue #63: [Bug] create producer and close producer in send callback will dead lock

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #63:
URL: https://github.com/apache/pulsar-client-cpp/issues/63#issuecomment-1305862187

   It's an incorrect use to call a synchronous API in the callback of an asynchronous API.
   
   For example, the following Java code also causes the deadlock.
   
   ```java
           @Cleanup final var client = PulsarClient.builder()
                   .serviceUrl(Config.BROKER_URL)
                   .build();
           @Cleanup final var producer = client.newProducer(Schema.STRING)
                   .topic("my-topic")
                   .create();
           producer.sendAsync("hello").thenAccept(msgId -> {
               try {
                   producer.close();
                   System.out.println("Producer closed");
               } catch (PulsarClientException e) {
                   throw new RuntimeException(e);
               }
           }).get();
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org