-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[broker] Fix error code returned to client when service unit is not ready #8147
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
Merged
+57
−8
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codelipenghui
approved these changes
Sep 30, 2020
sijie
approved these changes
Oct 1, 2020
lbenc135
pushed a commit
to lbenc135/pulsar
that referenced
this pull request
Oct 3, 2020
…che#8147) ### Motivation The other day, when a namespace bundle was unloaded, the broker got the following exception: ``` 18:30:35.309 [ForkJoinPool.commonPool-worker-60] WARN o.a.pulsar.broker.service.ServerCnx - [/xxx.xxx.xxx.xxx:45182][persistent://xxx/xxx/xxx][xxx] Failed to create consumer: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx java.util.concurrent.CompletionException: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:326) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:998) at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2137) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$13(ServerCnx.java:682) at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616) at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575) at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:943) at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:163) Caused by: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at org.apache.pulsar.broker.service.BrokerService.checkTopicNsOwnership(BrokerService.java:1016) at org.apache.pulsar.broker.service.persistent.PersistentTopic.subscribe(PersistentTopic.java:509) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$10(ServerCnx.java:699) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:995) ... 12 common frames omitted Caused by: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx ... 16 common frames omitted ``` If a `ServiceUnitNotReadyException` occurs on the broker side, the client should receive a `ServiceNotReady` error. However, the client received an `UnknownError` at this time. The broker was unable to return the correct error code to the client because the `ServiceUnitNotReadyException` was wrapped by a `RuntimeException`. Broker returns an `UnknownError` if an unknown exception is thrown: https://github.com/apache/pulsar/blob/f8b2a2334fb7d2dc5266242a6393c9cc434fba60/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerServiceException.java#L184-L224 ### Modifications Fixed the `BrokerService#checkTopicNsOwnership(String)` method to throw a `BrokerServiceException` instead of a `RuntimeException`.
wolfstudy
pushed a commit
that referenced
this pull request
Oct 30, 2020
### Motivation The other day, when a namespace bundle was unloaded, the broker got the following exception: ``` 18:30:35.309 [ForkJoinPool.commonPool-worker-60] WARN o.a.pulsar.broker.service.ServerCnx - [/xxx.xxx.xxx.xxx:45182][persistent://xxx/xxx/xxx][xxx] Failed to create consumer: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx java.util.concurrent.CompletionException: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:326) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:998) at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2137) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$13(ServerCnx.java:682) at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616) at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575) at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:943) at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:163) Caused by: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at org.apache.pulsar.broker.service.BrokerService.checkTopicNsOwnership(BrokerService.java:1016) at org.apache.pulsar.broker.service.persistent.PersistentTopic.subscribe(PersistentTopic.java:509) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$10(ServerCnx.java:699) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:995) ... 12 common frames omitted Caused by: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx ... 16 common frames omitted ``` If a `ServiceUnitNotReadyException` occurs on the broker side, the client should receive a `ServiceNotReady` error. However, the client received an `UnknownError` at this time. The broker was unable to return the correct error code to the client because the `ServiceUnitNotReadyException` was wrapped by a `RuntimeException`. Broker returns an `UnknownError` if an unknown exception is thrown: https://github.com/apache/pulsar/blob/f8b2a2334fb7d2dc5266242a6393c9cc434fba60/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerServiceException.java#L184-L224 ### Modifications Fixed the `BrokerService#checkTopicNsOwnership(String)` method to throw a `BrokerServiceException` instead of a `RuntimeException`. (cherry picked from commit abe9222)
huangdx0726
pushed a commit
to huangdx0726/pulsar
that referenced
this pull request
Nov 13, 2020
…che#8147) ### Motivation The other day, when a namespace bundle was unloaded, the broker got the following exception: ``` 18:30:35.309 [ForkJoinPool.commonPool-worker-60] WARN o.a.pulsar.broker.service.ServerCnx - [/xxx.xxx.xxx.xxx:45182][persistent://xxx/xxx/xxx][xxx] Failed to create consumer: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx java.util.concurrent.CompletionException: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:326) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:998) at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2137) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$13(ServerCnx.java:682) at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616) at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488) at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575) at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:943) at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:457) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:163) Caused by: java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx at org.apache.pulsar.broker.service.BrokerService.checkTopicNsOwnership(BrokerService.java:1016) at org.apache.pulsar.broker.service.persistent.PersistentTopic.subscribe(PersistentTopic.java:509) at org.apache.pulsar.broker.service.ServerCnx.lambda$null$10(ServerCnx.java:699) at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:995) ... 12 common frames omitted Caused by: org.apache.pulsar.broker.service.BrokerServiceException$ServiceUnitNotReadyException: Namespace bundle for topic (persistent://xxx/xxx/xxx) not served by this instance. Please redo the lookup. Request is denied: namespace=xxx/xxx ... 16 common frames omitted ``` If a `ServiceUnitNotReadyException` occurs on the broker side, the client should receive a `ServiceNotReady` error. However, the client received an `UnknownError` at this time. The broker was unable to return the correct error code to the client because the `ServiceUnitNotReadyException` was wrapped by a `RuntimeException`. Broker returns an `UnknownError` if an unknown exception is thrown: https://github.com/apache/pulsar/blob/f8b2a2334fb7d2dc5266242a6393c9cc434fba60/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerServiceException.java#L184-L224 ### Modifications Fixed the `BrokerService#checkTopicNsOwnership(String)` method to throw a `BrokerServiceException` instead of a `RuntimeException`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The other day, when a namespace bundle was unloaded, the broker got the following exception:
If a
ServiceUnitNotReadyException
occurs on the broker side, the client should receive aServiceNotReady
error. However, the client received anUnknownError
at this time.The broker was unable to return the correct error code to the client because the
ServiceUnitNotReadyException
was wrapped by aRuntimeException
. Broker returns anUnknownError
if an unknown exception is thrown:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerServiceException.java
Lines 184 to 224 in f8b2a23
Modifications
Fixed the
BrokerService#checkTopicNsOwnership(String)
method to throw aBrokerServiceException
instead of aRuntimeException
.