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
Add more info in the error messages #5714
Conversation
--- *Modifications* Add topic name in the producer timeout error.
run java8 tests |
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.
There are multiple places that TimeoutException can occur. I would suggest fixing all places that TimeoutException is thrown.
- ClientCnx: topic lookup requests can be timed out.
- Producer: send requests can be timed out.
- Consumer: getLastMessageId can be timed out.
I am sure there are more client exceptions that require topic name in the error messages. so please fix them as well.
run java8 tests |
The unit test seems failed caused by my fix. I am fixing the test. |
@sijie One is we get an exception and throw it out.
Another is we wrap the exception with the
If the exception belongs to the second one, I can add the info message easily. Otherwise, I think it has a risk to update the Exception If I don't know the exception is caught by others for retrying or do something others. How do you think? |
In the first case, you need to find where the exception was first raised and fix it, no? |
Yes. There are many exceptions thrown by |
for the exceptions raised by ClientCnx, it is making more sense to catch the exception at the caller (Producer, Consumer) and attach the topic information to the exception, rather than passing the topic name information into ClientCnx. |
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BinaryProtoLookupService.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
Outdated
Show resolved
Hide resolved
@@ -1466,7 +1480,10 @@ public void seek(long timestamp) throws PulsarClientException { | |||
seekFuture.complete(null); | |||
}).exceptionally(e -> { | |||
log.error("[{}][{}] Failed to reset subscription: {}", topic, subscription, e.getCause().getMessage()); | |||
seekFuture.completeExceptionally(e.getCause()); | |||
seekFuture.completeExceptionally( | |||
new PulsarClientException.WrapperException( |
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 am not sure WrapperException is the right fix here. because it will change the client behavior. for example, if a client used to handle exeception A, now we are throwing a WrapperException of A.
We should reconstruct a A with an updated error message and its stack trace.
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.
if the A is thrown by ClientCnx
, we reconstruct the A it might still change the client's behavior.
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.
But it seems if I want to add the error message there are two ways to update. One is updating the error message before the exception throws. Another is unwrapping the wrapper when the method needs to handle the exception.
@sijie I add a new method The wrap method will get the exception and wrap the old exception with the same type of the exception, so I can add more message info to the exception. I run the test that failed before, it can be passed on my laptop. What do you think? |
run java8 tests |
@sijie PTAL. Thanks |
run cpp tests |
1 similar comment
run cpp tests |
@sijie PTAL. Thanks. |
Modifications
Add topic and subscription info in the error message to help locate the problem that which topic or subscription throws the error.