-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ServerCnx] Improve error logging for topic not found #13950
[ServerCnx] Improve error logging for topic not found #13950
Conversation
ServiceUnitNotReadyException.class, ManagedLedgerException.class)) { | ||
// Do not print stack traces for expected exceptions | ||
log.error("[{}] Failed to create topic {}, producerId={}", | ||
remoteAddress, topicName, producerId, exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still print the exception stack in exception
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still prints the exception stack here, but it doesn't for exceptions that have a cause of type NoSuchElementException
. I relocated the comment because we're avoiding printing stack traces in this conditional block.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Outdated
Show resolved
Hide resolved
@@ -1273,12 +1273,13 @@ protected void handleProducer(final CommandProducer cmdProducer) { | |||
return null; | |||
} | |||
|
|||
// Do not print stack traces for expected exceptions | |||
if (cause instanceof NoSuchElementException) { | |||
cause = new TopicNotFoundException("Topic Not Found."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could also try to not create a 2nd exception here which is only used to do getMessage()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, although we also use the exception here: BrokerServiceException.getClientErrorCode(cause)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merlimat - would you like me to introduce more complicated logic for getting the client error code, or is this sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@michaeljmarshall The C++ tests have already been fixed by disabling |
@BewareMyPower - thanks, for your note--that last retry worked. I am going to merge this now and we can revisit the exception later, if it's an issue. |
Motivation
When trying to load a topic without auto topic creation enabled, the broker logs a large stack trace that isn't very helpful. The error isn't helpful because the stack trace is truncated and because it comes from calling
.get
on an empty optionalpulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Line 904 in 2285d02
Here is a sample stack trace:
I would have preferred to modify the
getOrCreateTopic
method, but it seems that method won't be easy to modify without touching a bunch of tests. Instead, I update theexceptionally
block to improve our handling of the failed topic load.Modifications
NoSuchElementException
. This case happens when auto topic creation is turned off.Verifying this change
This is a trivial change to a log line, so I do not have any tests.
Does this pull request potentially affect one of the following parts:
There are no breaking/public changes here.
Documentation
no-need-doc
This update only affects a log line, so it doesn't need documentation.