Fix ack failure on message listener in multi topics consumer#447
Merged
BewareMyPower merged 2 commits intoapache:mainfrom Oct 11, 2024
Merged
Fix ack failure on message listener in multi topics consumer#447BewareMyPower merged 2 commits intoapache:mainfrom
BewareMyPower merged 2 commits intoapache:mainfrom
Conversation
c3d42df to
58d3122
Compare
58d3122 to
2e663c4
Compare
Contributor
BewareMyPower
left a comment
There was a problem hiding this comment.
Could you add a test for it?
Contributor
Okay, I see it. |
BewareMyPower
approved these changes
Oct 11, 2024
4 tasks
4 tasks
BewareMyPower
pushed a commit
that referenced
this pull request
Apr 22, 2025
…481) This was introduced in v3.7.0 via #447, which contained a change that attempted to fix an issue where a pre-mature ack of a message before a multi-topic subscriber was ready could have caused a crash. To fix the original bug, all multi-topic subscriptions are started with their message listener paused. They later get un-paused once all topics are successfully subscribed and connected. However, on a regex subscription when new topics are discovered, they also start in a paused state, and there's no mechanism to resume them. Hence, they get stuck, and no messages for new topics will be processed. This change adds a call to resume any new listeners after new topics are added.
BewareMyPower
pushed a commit
that referenced
this pull request
Apr 28, 2025
…481) This was introduced in v3.7.0 via #447, which contained a change that attempted to fix an issue where a pre-mature ack of a message before a multi-topic subscriber was ready could have caused a crash. To fix the original bug, all multi-topic subscriptions are started with their message listener paused. They later get un-paused once all topics are successfully subscribed and connected. However, on a regex subscription when new topics are discovered, they also start in a paused state, and there's no mechanism to resume them. Hence, they get stuck, and no messages for new topics will be processed. This change adds a call to resume any new listeners after new topics are added. (cherry picked from commit 0a9b7d9)
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
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.
Fixes #446
Motivation
We found an ack failure issue: #446
MessageListeners can start to process messages before subscribing all child topics are completed in "multi topics" (e.g. partitioned, list, regex) cases.
If
acknowledge()is called in messageListeners (it is very typical usage) before subscribing completion, it will fail withAlreadyClosederror since the state of the parent consumer is notReadyyet:pulsar-client-cpp/lib/MultiTopicsConsumerImpl.cc
Lines 643 to 648 in 8b2753a
That results in ack holes, and finally full backlog.
Modifications
MultiTopicsConsumerImpl: Pause messageListeners at first by settingstartPausedto true and resume them after subscribing all child topics are completed.ConsumerImpl: Delete unused code.sendFlowPermitsToBroker()at the first connection.firstTimelooks always false atpulsar-client-cpp/lib/ConsumerImpl.cc
Line 316 in 8b2753a
pulsar-client-cpp/lib/ConsumerImpl.cc
Lines 297 to 299 in 8b2753a
ConsumerImplinstances, whereas it has no chance of returning to true once it becomes false.Verifying this change
Specific tests for this issue is difficult to implement because it does not occur every time.
Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)