Skip to content

Commit

Permalink
[Broker] Handle all exceptions from topic.addProducer (apache#6881)
Browse files Browse the repository at this point in the history
Fixes apache#6872
Fixes apache#6416

If a producer tries to create a producer to a topic that is currently
unloading, we can get a `RuntimeException` from
`BrokerService.checkTopicNsOwnership` which is bubbled up through
`topic.addProducer`. By only handling a `BrokerServiceException` this
results in a future that never completes and results in producers not
being able to be created if this topic is scheduled back to this broker.
  • Loading branch information
addisonj authored and huangdx0726 committed Aug 24, 2020
1 parent c2235d7 commit 48dd92a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ protected void handleProducer(final CommandProducer cmdProducer) {
ServerError error = null;
if(!existingProducerFuture.isDone()) {
error = ServerError.ServiceNotReady;
}else {
} else {
error = getErrorCode(existingProducerFuture);
// remove producer with producerId as it's already completed with exception
producers.remove(producerId);
Expand Down Expand Up @@ -1091,7 +1091,7 @@ protected void handleProducer(final CommandProducer cmdProducer) {
producerFuture.completeExceptionally(
new IllegalStateException("Producer created after connection was closed"));
}
} catch (BrokerServiceException ise) {
} catch (Exception ise) {
log.error("[{}] Failed to add producer to topic {}: {}", remoteAddress, topicName,
ise.getMessage());
ctx.writeAndFlush(Commands.newError(requestId,
Expand Down

0 comments on commit 48dd92a

Please sign in to comment.