Skip to content
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

Merged
merged 5 commits into from Dec 9, 2019
Merged

Add more info in the error messages #5714

merged 5 commits into from Dec 9, 2019

Conversation

zymap
Copy link
Member

@zymap zymap commented Nov 21, 2019


Modifications

Add topic and subscription info in the error message to help locate the problem that which topic or subscription throws the error.

---

*Modifications*

Add topic name in the producer timeout error.
@codelipenghui
Copy link
Contributor

run java8 tests
run integration tests

Copy link
Member

@sijie sijie left a 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.

@sijie
Copy link
Member

sijie commented Nov 21, 2019

run java8 tests

@zymap zymap changed the title Add topic name in the producer timeout error Add more info in the error messages Nov 25, 2019
@zymap
Copy link
Member Author

zymap commented Nov 26, 2019

The unit test seems failed caused by my fix. I am fixing the test.

@zymap
Copy link
Member Author

zymap commented Nov 26, 2019

@sijie
There are two ways when we threw an Exception.

One is we get an exception and throw it out.

future.exceptionally(e -> {
       anotherFuture.completeExceptionally(e)
})

Another is we wrap the exception with the PulsarClientException.

future.exceptionally(e -> {
       anotherFuture.completeExceptinoally(new PulsarClientException())
})

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?

@sijie
Copy link
Member

sijie commented Nov 26, 2019

In the first case, you need to find where the exception was first raised and fix it, no?

@zymap
Copy link
Member Author

zymap commented Nov 27, 2019

Yes. There are many exceptions thrown by ClientCnx. In ClientCnx, it using a map to save requestId and CompleableFuture. And the requestId is generated from other places like ConsumerImpl or ProducerImpl or LookupService. Should I pass the topic name from the Consumerimpl and combine it with requestId? If so I can get the topic name or other information when the future complete exceptionally.

@sijie
Copy link
Member

sijie commented Nov 27, 2019

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.

@@ -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(
Copy link
Member

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.

Copy link
Member Author

@zymap zymap Dec 2, 2019

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.

Copy link
Member Author

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.

@zymap
Copy link
Member Author

zymap commented Dec 3, 2019

@sijie I add a new method wrap to wrap the exception to enriching the exception message info.

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?

@zymap
Copy link
Member Author

zymap commented Dec 5, 2019

run java8 tests
run integration tests
run cpp tests

@zymap
Copy link
Member Author

zymap commented Dec 5, 2019

@sijie PTAL. Thanks

@sijie
Copy link
Member

sijie commented Dec 8, 2019

run cpp tests

1 similar comment
@zymap
Copy link
Member Author

zymap commented Dec 9, 2019

run cpp tests

@zymap
Copy link
Member Author

zymap commented Dec 9, 2019

@sijie PTAL. Thanks.

@sijie sijie modified the milestones: 2.4.3, 2.6.0, 2.5.1 Dec 9, 2019
@sijie sijie merged commit a8c8a7e into apache:master Dec 9, 2019
@sijie sijie modified the milestones: 2.5.1, 2.5.0 Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants