apache / apache/pulsar-client-go
Regex consumer throws multiple unnecessary errors on topic deletion
- Dominant language
- Go
- Stars
- 745
- Forks
- 389
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 3
Description
#### Expected behavior
When a topic is deleted, a regex subscriber should simply gracefully close the individual consumer and move on.
#### Actual behavior
As I mention in #432, the client throws a series of scary-looking errors as it attempts to resubscribe to the topic, but is blocked by its own specified desire not to create new topics. It then retries the operation a series of times.
#### Steps to reproduce
As with #432, once #433 is applied.
#### Suggested fix
Since the consumer already knows it doesn't want to create a new topic, and since the error returned from the server explicitly states that the topic doesn't exist, the consumer could put two and two together and realize that it shouldn't keep retrying the consumer. Unfortunately, at the moment, the error is returned from `connection.handleResponseError()` as a string:
```go
errMsg := fmt.Sprintf("server error: %s: %s", serverError.GetError(), serverError.GetMessage())
```
Since `handleResponseError()` already has the `*pb.CommandError`, it could conceivably wrap the message in a type like the following
```go
type commandError struct {
serverErrorType string
serverErrorMsg string
}
```
Because `ServerError` [is a proto enum](https://github.com/apache/pulsar/blob/73e0dbd4df36571460eeb070964ec498d1955c1d/pulsar-common/src/main/proto/PulsarApi.proto#L189), it should be safe enough to just call `Enum().String()` and select off of that when handling the error.
Contributor guide
Research direction
Start with connection.handleResponseError() and trace how its *pb.CommandError result reaches the regex consumer's resubscription path after a topic deletion. Reproduce the scenario described in #432 and #433 with topic creation disabled, then verify that a missing topic causes the individual consumer to close and move on without repeated errors or retries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100