[ISSUE #479]fix: duplicate pulls due to concurrency issues in rebalance.#480
Open
humkum wants to merge 1 commit intoapache:masterfrom
Open
[ISSUE #479]fix: duplicate pulls due to concurrency issues in rebalance.#480humkum wants to merge 1 commit intoapache:masterfrom
humkum wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
Author
|
@ShannonDing @ifplusor Could you please help to review this pr? |
ifplusor
requested changes
Dec 21, 2024
Contributor
|
|
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.
fix #479
根因分析
根因:AsyncPullCallback 构建存在并发问题,导致多个 pull 线程消费同一个队列。
通过以上 5 个条件:如果两次 Rebalance 相隔时间很短,mq 对应的之前的 PullRequest 还来不及因设置为 drop 而结束当前的拉取。第二次 rebalance 就替换掉了 AsyncPullCallback 中的局部变量 PullRequest,导致上一次的拉取请求又拿到了非 drop 的 pullRequest。此时就会出现 2 个 pullRequest 同时拉取同一个队列的情况。依次类推,如果重复多次短时间 rebalance,单个分区可能存在多个 pullRequest 同时拉取。
新的 pullRequest 替换掉旧的 pullRequest, drop 状态被配置成了 false


上次还没处理结束的拉取线程因为状态变化不能正常退出