gaoran10 commented on code in PR #23074:
URL: https://github.com/apache/pulsar/pull/23074#discussion_r1692437424
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -1545,6 +1555,18 @@ protected void handleProducer(final CommandProducer
cmdProducer) {
}
service.getOrCreateTopic(topicName.toString()).thenCompose((Topic
topic) -> {
+ // Check max producer limitation to avoid unnecessary ops
wasting resources. For example: the new
+ // producer reached max producer limitation, but pulsar did
schema check first, it would waste CPU
+ if (((AbstractTopic) topic).isProducersExceeded(producerName))
{
+ log.warn("[{}] Attempting to add producer to topic which
reached max producers limit", topic);
+ String errorMsg = "Topic '" + topicName.toString() + "'
reached max producers limit";
+ Throwable t = new
BrokerServiceException.ProducerBusyException(errorMsg);
+ producerFuture.completeExceptionally(t);
+ producers.remove(producerId, producerFuture);
+ commandSender.sendErrorResponse(requestId,
BrokerServiceException.getClientErrorCode(t), errorMsg);
Review Comment:
Why not return a failed future object?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]