From b41a0203d311e4c034628b6d28c8f914871636bd Mon Sep 17 00:00:00 2001 From: Rajan Dhabalia Date: Sun, 7 Apr 2019 22:23:51 -0700 Subject: [PATCH] [pulsar-broker] add producer/consumer id in error-logging (#3961) ### Motivation Log Producer/Consumer Id when broker logs "Producer/consumer is already connected" to help in debugging when client is keep failing to create producer and broker is keep logging the same error. --- .../apache/pulsar/broker/service/ServerCnx.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java index 0659376b76e33..ff0c27ec2c03c 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java @@ -653,8 +653,8 @@ protected void handleSubscribe(final CommandSubscribe subscribe) { if (existingConsumerFuture != null) { if (existingConsumerFuture.isDone() && !existingConsumerFuture.isCompletedExceptionally()) { Consumer consumer = existingConsumerFuture.getNow(null); - log.info("[{}] Consumer with the same id is already created: {}", remoteAddress, - consumer); + log.info("[{}] Consumer with the same id {} is already created: {}", remoteAddress, + consumerId, consumer); ctx.writeAndFlush(Commands.newSuccess(requestId)); return null; } else { @@ -663,8 +663,8 @@ protected void handleSubscribe(final CommandSubscribe subscribe) { // client timeout is lower the broker timeouts. We need to wait until the previous // consumer // creation request either complete or fails. - log.warn("[{}][{}][{}] Consumer is already present on the connection", remoteAddress, - topicName, subscriptionName); + log.warn("[{}][{}][{}] Consumer with id {} is already present on the connection", remoteAddress, + topicName, subscriptionName, consumerId); ServerError error = !existingConsumerFuture.isDone() ? ServerError.ServiceNotReady : getErrorCode(existingConsumerFuture); ctx.writeAndFlush(Commands.newError(requestId, error, @@ -841,8 +841,8 @@ protected void handleProducer(final CommandProducer cmdProducer) { if (existingProducerFuture != null) { if (existingProducerFuture.isDone() && !existingProducerFuture.isCompletedExceptionally()) { Producer producer = existingProducerFuture.getNow(null); - log.info("[{}] Producer with the same id is already created: {}", remoteAddress, - producer); + log.info("[{}] Producer with the same id {} is already created: {}", remoteAddress, + producerId, producer); ctx.writeAndFlush(Commands.newProducerSuccess(requestId, producer.getProducerName(), producer.getSchemaVersion())); return null; @@ -856,8 +856,8 @@ protected void handleProducer(final CommandProducer cmdProducer) { // either complete or fails. ServerError error = !existingProducerFuture.isDone() ? ServerError.ServiceNotReady : getErrorCode(existingProducerFuture); - log.warn("[{}][{}] Producer is already present on the connection", remoteAddress, - topicName); + log.warn("[{}][{}] Producer with id {} is already present on the connection", remoteAddress, + producerId, topicName); ctx.writeAndFlush(Commands.newError(requestId, error, "Producer is already present on the connection")); return null;