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

When topic is terminated. Client must not retry connecting to broker. #1128

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

pkumar-singh
Copy link
Member

Motivation

GoLang Pulsar client library has no support for Topic termination.
When a topic is terminated following should happen at client library side.

  1. Producers should stop reconnecting. As once topic is terminated, it is permanent.
  2. All the pending messages should be failed.

Modifications

If reconnect is failing with TopicTerminated error.
Run through the pending messages queue and complete the callback.
After that exit the reconnect loop and set producer state as closing.
Marking producer state producerClosing will ensure that new messages are immediately failed.

pulsar/producer_partition.go Outdated Show resolved Hide resolved
Copy link
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests to verify it?

@pkumar-singh
Copy link
Member Author

Could you add some tests to verify it?

Done.!

Copy link
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@RobertIndie RobertIndie merged commit ec846ff into apache:master Nov 16, 2023
6 checks passed
@RobertIndie RobertIndie added this to the v0.12.0 milestone Nov 16, 2023
pkumar-singh added a commit to pkumar-singh/pulsar-client-go that referenced this pull request Nov 21, 2023
…ding messages should be failed (apache#1128)

GoLang Pulsar client library has no support for Topic termination.
When a topic is terminated following should happen at client library side.
1. Producers should stop reconnecting. As once topic is terminated, it is permanent.
2. All the pending messages should be failed.

If reconnect is failing with TopicTerminated error.
Run through the pending messages queue and complete the callback.
After that exit the reconnect loop and set producer state as closing.
Marking producer state producerClosing will ensure that new messages are immediately failed.

Co-authored-by: Prashant Kumar <prashantk@splunk.com>
RobertIndie pushed a commit that referenced this pull request Dec 8, 2023
…uotaExceededException/ProducerFenced when reconnecting (#1134)

Master Issue: #1128

### Motivation

In Java client, when we get TopicNotFound/TopicTerminated/ProducerBlockedQuotaExceededException/ProducerFenced, we should failPendingMessages, and close producer. But in Go client, we forget to handle ProducerBlockedQuotaExceededException/ProducerFenced, and in #1128, we just call sr.done(), actually we should call failPendingMessages().

https://github.com/apache/pulsar-client-go/pull/1128/files
https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L1663

### Modifications
1. rename `errMsgTopicNotFount` to `errMsgTopicNotFound`
2. handle TopicTerminated/ProducerBlockedQuotaExceededException/ProducerFenced, call `failPendingMessages()`;

---------

Co-authored-by: gunli <gunli@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants