Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 13 additions & 3 deletions lib/ConsumerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,27 @@ ConsumerImpl::~ConsumerImpl() {
// 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");
auto client = client_.lock();
if (client) {
LOG_WARN(consumerStr_ << "Destroyed consumer which was not properly closed");
} else {
LOG_DEBUG(consumerStr_
<< "Destroyed consumer which was not properly closed (client already destroyed)");
}

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_);
LOG_DEBUG(consumerStr_ << "Closed consumer for race condition: " << consumerId_);
} else {
LOG_WARN(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
if (client) {
LOG_WARN(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
} else {
LOG_DEBUG(consumerStr_ << "Client is destroyed and cannot send the CloseConsumer command");
}
}
}
internalShutdown();
Expand Down
14 changes: 10 additions & 4 deletions lib/ProducerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ ProducerImpl::~ProducerImpl() {
internalShutdown();
printStats();
if (state_ == Ready || state_ == Pending) {
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
auto client = client_.lock();
if (client) {
LOG_WARN(producerStr_ << "Destroyed producer which was not properly closed");
} else {
LOG_DEBUG(producerStr_
<< "Destroyed producer which was not properly closed (client already destroyed)");
}
}
}

Expand Down Expand Up @@ -753,10 +759,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