Skip to content

[ISSUE #10435] Fix shared ClientChannelInfo preventing inactive channel expiry#10437

Open
chuanxo wants to merge 2 commits into
apache:developfrom
chuanxo:fix-shared-client-channel-info_
Open

[ISSUE #10435] Fix shared ClientChannelInfo preventing inactive channel expiry#10437
chuanxo wants to merge 2 commits into
apache:developfrom
chuanxo:fix-shared-client-channel-info_

Conversation

@chuanxo

@chuanxo chuanxo commented Jun 7, 2026

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Brief Description

ClientManageProcessor.heartBeat() 在循环外只创建了一个 ClientChannelInfo 实例,多个 consumer/producer group 共享同一引用。ConsumerGroupInfo.updateChannel() 更新 lastUpdateTimestamp 时会影响所有 group,导致 scanNotActiveChannel() 无法正确过期清理已下线的 group channel。

修复方式:将 new ClientChannelInfo(...) 移到循环体内,每个 group 持有独立实例。

How Did You Test This Change?

ClientManageProcessorTest 中新增 testHeartbeatMultiGroupChannelIndependentExpiry,验证多 group 心跳场景下各 group 的 ClientChannelInfo 互相独立,未续期的 group channel 能被正常过期清理。

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

This PR fixes a bug where ClientChannelInfo was shared across multiple consumer/producer groups in the heartbeat processing loop, causing incorrect channel expiry behavior.

Findings

  • [Info] broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java:81-87 — Moved ClientChannelInfo creation into the heartBeatV2 branch, ensuring each code path creates its own instance.
  • [Info] broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java:125-130 — Creates ClientChannelInfo inside the consumer group loop, so each group gets an independent instance.
  • [Info] broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java:149-154 — Creates ClientChannelInfo inline for producer registration, maintaining consistency.
  • [Info] broker/src/test/java/org/apache/rocketmq/broker/processor/ClientManageProcessorTest.java:223-276 — Excellent test coverage. The new test testHeartbeatMultiGroupChannelIndependentExpiry specifically validates the bug scenario: two groups share a heartbeat, then only one continues, and the other should be evicted.

Suggestions

The fix is correct and minimal. The performance impact of creating more ClientChannelInfo objects is negligible compared to the correctness gain. The test directly reproduces the reported issue and verifies the fix.

Verdict

Approved — Clean fix for a real concurrency bug with good test coverage.


Automated review by github-manager-bot

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.98%. Comparing base (7e0cec3) to head (1b475c6).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
...cketmq/broker/processor/ClientManageProcessor.java 71.42% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10437      +/-   ##
=============================================
- Coverage      48.04%   47.98%   -0.06%     
+ Complexity     13305    13288      -17     
=============================================
  Files           1377     1377              
  Lines         100613   100641      +28     
  Branches       12992    12995       +3     
=============================================
- Hits           48341    48295      -46     
- Misses         46354    46397      +43     
- Partials        5918     5949      +31     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[Bug] Shared ClientChannelInfo in heartBeat() prevents scanNotActiveChannel from expiring stale groups

3 participants