Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/BatchMessageContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ namespace pulsar {
BatchMessageContainer::BatchMessageContainer(const ProducerImpl& producer)
: BatchMessageContainerBase(producer) {}

BatchMessageContainer::~BatchMessageContainer() {
LOG_DEBUG(*this << " destructed");
LOG_DEBUG("[numberOfBatchesSent = " << numberOfBatchesSent_
<< "] [averageBatchSize_ = " << averageBatchSize_ << "]");
}
BatchMessageContainer::~BatchMessageContainer() {}

bool BatchMessageContainer::add(const Message& msg, const SendCallback& callback) {
LOG_DEBUG("Before add: " << *this << " [message = " << msg << "]");
Expand Down
6 changes: 1 addition & 5 deletions lib/BatchMessageKeyBasedContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ inline std::string getKey(const Message& msg) {
BatchMessageKeyBasedContainer::BatchMessageKeyBasedContainer(const ProducerImpl& producer)
: BatchMessageContainerBase(producer) {}

BatchMessageKeyBasedContainer::~BatchMessageKeyBasedContainer() {
LOG_DEBUG(*this << " destructed");
LOG_INFO("[numberOfBatchesSent = " << numberOfBatchesSent_
<< "] [averageBatchSize_ = " << averageBatchSize_ << "]");
}
BatchMessageKeyBasedContainer::~BatchMessageKeyBasedContainer() {}

bool BatchMessageKeyBasedContainer::isFirstMessageToAdd(const Message& msg) const {
auto it = batches_.find(getKey(msg));
Expand Down
9 changes: 4 additions & 5 deletions lib/ConsumerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,22 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr& client, const std::string& topic
}

ConsumerImpl::~ConsumerImpl() {
LOG_DEBUG(consumerStr_ << "~ConsumerImpl");
auto client = client_.lock();
if (state_ == Ready) {
// this could happen at least in this condition:
// consumer seek, caused reconnection, if consumer close happened before connection ready,
// then consumer will not send closeConsumer to Broker side, and caused a leak of consumer in
// broker.
LOG_WARN(consumerStr_ << "Destroyed consumer which was not properly closed");
if (client) {
LOG_WARN(consumerStr_ << "Destroyed consumer which was not properly closed");
}

ClientConnectionPtr cnx = getCnx().lock();
if (cnx) {
auto requestId = newRequestId();
cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId,
"CLOSE_CONSUMER");
cnx->removeConsumer(consumerId_);
LOG_INFO(consumerStr_ << "Closed consumer for race condition: " << consumerId_);
} else {
LOG_WARN(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
}
}
internalShutdown();
Expand Down
16 changes: 9 additions & 7 deletions lib/ProducerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ ProducerImpl::ProducerImpl(const ClientImplPtr& client, const TopicName& topicNa
}

ProducerImpl::~ProducerImpl() {
LOG_DEBUG(producerStr_ << "~ProducerImpl");
auto client = client_.lock();
internalShutdown();
printStats();
if (state_ == Ready || state_ == Pending) {
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
if (client) {
printStats();
if (state_ == Ready || state_ == Pending) {
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
}
}
}

Expand Down Expand Up @@ -753,10 +755,10 @@ void ProducerImpl::sendMessage(std::unique_ptr<OpSendMsg> opSendMsg) {

void ProducerImpl::printStats() {
if (batchMessageContainer_) {
LOG_INFO("Producer - " << producerStr_ << ", [batchMessageContainer = " << *batchMessageContainer_
<< "]");
LOG_DEBUG("Producer - " << producerStr_ << ", [batchMessageContainer = " << *batchMessageContainer_
<< "]");
} else {
LOG_INFO("Producer - " << producerStr_ << ", [batching = off]");
LOG_DEBUG("Producer - " << producerStr_ << ", [batching = off]");
}
}

Expand Down
Loading