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

double check before consumer reconnect #1084

Merged
merged 1 commit into from
Oct 21, 2023

Conversation

zccold
Copy link
Contributor

@zccold zccold commented Aug 24, 2023

Motivation

I have a topic with 4 partitions and multiple subscriptions. One of the subscriptions (in keyshared mode) is stuck while consuming from one partition, while the other subscriptions and this particular subscription consuming from other partitions are working fine.
After communicating with the cloud service provider, they believe that it is caused by a consumer not acknowledging the messages it received. However, in my code, I have closed the consumer, so the server should not be waiting indefinitely.
After checking the logs and the code, I believe the situation was as follows:

  1. The server notifies the consumer to reconnect and starts sleeping at this line: https://github.com/apache/pulsar-client-go/blob/master/pulsar/consumer_partition.go#L1645.
  2. In my code logic, I closed the consumer. At this point, since the connection is closed, the corresponding error message is printed in the log: [Failed to close consumer], err: connection closed
  3. The sleep ends, the reconnect is successful, but this new connection is leaked, and the messages within it cannot be consumed.
  4. In my code logic, I recreate the consumer, but due to the issue in the previous step, the new consumer is unable to receive any messages.

Modifications

In the reconnectToBroker method, after the sleep, a double check is performed to confirm the status of the consumer.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@BewareMyPower BewareMyPower changed the title dobule check before consumer reconnect double check before consumer reconnect Sep 13, 2023
@BewareMyPower BewareMyPower added this to the v0.12.0 milestone Sep 13, 2023
@dao-jun dao-jun merged commit da06dca into apache:master Oct 21, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants