jiazhai opened a new pull request #7793:
URL: https://github.com/apache/pulsar/pull/7793


   Marked as WIP to wait for verifying in valgrind.
   
   ### Motivation
   User reports a valgrind error for `client::createReader` method:
   
   ```
   ==23308== 284,826 (160 direct, 284,666 indirect) bytes in 1 blocks are 
definitely lost in loss record 113 of 113
   ==23308==    at 0x4C2A593: operator new(unsigned long) 
(vg_replace_malloc.c:344)
   ==23308==    by 0x5303B4A: allocate (new_allocator.h:104)
   ==23308==    by 0x5303B4A: allocate (alloc_traits.h:351)
   ==23308==    by 0x5303B4A: 
__shared_count<pulsar::InternalState<pulsar::Result, pulsar::Reader>, 
std::allocator<pulsar::InternalState<pulsar::Result, pulsar::Reader> > > 
(shared_ptr_base.h:499)
   ==23308==    by 0x5303B4A: 
__shared_ptr<std::allocator<pulsar::InternalState<pulsar::Result, 
pulsar::Reader> > > (shared_ptr_base.h:957)
   ==23308==    by 0x5303B4A: 
shared_ptr<std::allocator<pulsar::InternalState<pulsar::Result, pulsar::Reader> 
> > (shared_ptr.h:316)
   ==23308==    by 0x5303B4A: 
allocate_shared<pulsar::InternalState<pulsar::Result, pulsar::Reader>, 
std::allocator<pulsar::InternalState<pulsar::Result, pulsar::Reader> > > 
(shared_ptr.h:598)
   ==23308==    by 0x5303B4A: make_shared<pulsar::InternalState<pulsar::Result, 
pulsar::Reader> > (shared_ptr.h:614)
   ==23308==    by 0x5303B4A: Promise (Future.h:91)
   ==23308==    by 0x5303B4A: pulsar::Client::createReader(std::string const&, 
pulsar::MessageId const&, pulsar::ReaderConfiguration const&, pulsar::Reader&) 
(Client.cc:142)
   ==23308==    by 0x401DDB: main (pulsarReader.cpp:92)
   ==23308== 
   ```
   It seems the `consumer_` in `ReaderImpl` has been tracked twice. this PR is 
to fix the issue.
   
   ### Modifications
   
   - release reference when reader close.
   - add test for the reference issue.
   
   ### Verifying this change
   ut passed.


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


Reply via email to