[ISSUE #9633] Enable retry topic V2 by default to prevent name collision#10565
[ISSUE #9633] Enable retry topic V2 by default to prevent name collision#10565wang-jiahua wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses retry-topic name collisions in POP retry topic V1 (%RETRY%{cid}_{topic}) by enabling the collision-free V2 naming scheme (%RETRY%{cid}+{topic}) by default in BrokerConfig, while keeping V1 retry-topic retrieval enabled for backward compatibility.
Changes:
- Switch
BrokerConfig.enableRetryTopicV2default fromfalsetotrue. - Add unit tests demonstrating a concrete V1 collision case and verifying V2 avoids it.
- Add a unit test asserting the new default for
enableRetryTopicV2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java | Enables retry topic V2 by default to avoid V1 name collisions. |
| common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java | Adds tests covering V1 collision behavior, V2 non-collision, and the new default config value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Changes enableRetryTopicV2 default from false to true, fixing the V1 retry topic naming collision where different (group, topic) pairs can produce the same retry topic name (e.g., group="A_B", topic="C" and group="A", topic="B_C" both yield %RETRY%A_B_C).
Findings
- [Info]
BrokerConfig.java:240— Single-line default change. V2 uses+separator which is not allowed in topic/group names, eliminating ambiguity. - [Info] Backward compatibility is maintained:
retrieveMessageFromPopRetryTopicV1remainstrue, so existing V1 retry topics are still readable during and after upgrade. - [Info] Tests are well-structured:
testV1CollisionExampledemonstrates the bug,testV2NoCollisionproves the fix,testDefaultEnableRetryTopicV2IsTruelocks in the default. - [Warning]
KeyBuilderTest.java:89— Missing newline at end of file (trailing\ No newline at end of file). Minor style issue.
Suggestions
- Rolling upgrade consideration: During a rolling upgrade, some brokers may use V1 naming while others use V2. New messages will be routed to V2 retry topics on upgraded brokers. Ensure that consumers on older broker versions can still process messages from V2 retry topics, or document this as a known limitation.
- Consider adding a release note / migration guide entry since this changes default behavior.
Overall: correct fix for a fundamental naming design flaw. The backward compatibility path is properly preserved.
Automated review by github-manager-bot
…collision
V1 retry topic naming uses underscore as separator (%RETRY%{cid}_{topic}),
which is ambiguous because both topic and group names may contain underscores.
This causes different (group, topic) pairs to map to the same retry topic,
leading to cross-topic consumption and potential data leakage.
V2 naming (using '+' separator) already exists but was disabled by default.
This commit changes enableRetryTopicV2 default from false to true.
Existing V1 retry topics are still readable because
retrieveMessageFromPopRetryTopicV1 remains true (backward compatible).
Changes:
- BrokerConfig: enableRetryTopicV2 default false -> true
- KeyBuilderTest: 3 new tests demonstrating V1 collision and V2 correctness
8ff7c16 to
743e72f
Compare
|
I don't think we should enable retry topic V2 by default in this PR yet. Keeping Before changing the default, we should have explicit upgrade compatibility verification covering the V1 -> V2 transition, or keep |
|
Thanks for the feedback @qianye1001! You raise a valid point — enabling V2 by default is a significant behavior change. Given your concern, I have two options:
Which approach do you prefer? Or should I close this PR entirely? |
Review by github-manager-bot (Re-review after new commit)SummaryRe-reviewed after commit Assessment: ✅ Looks Good
Clean, well-scoped change with appropriate test coverage. |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot (Re-review after new commit)
Changes since last review
No functional changes detected. The commit appears to be a rebase or amend with the same content.
Previous findings (unchanged)
- [Warning]
KeyBuilderTest.java— Still missing newline at end of file. Trivial style issue, non-blocking.
Verdict
No new concerns. Previous review stands. LGTM 👍
Automated review by github-manager-bot
|
建议 close |
Which Issue(s) This PR Fixes
Fixes #9633
Brief Description
V1 retry topic naming uses underscore as separator (
%RETRY%{cid}_{topic}), which is ambiguous because both topic and group names may contain underscores. This causes different (group, topic) pairs to map to the same retry topic, leading to cross-topic consumption.V2 naming (using
+separator) already exists but was disabled by default. This PR changesenableRetryTopicV2default from false to true.Existing V1 retry topics are still readable because
retrieveMessageFromPopRetryTopicV1remains true (backward compatible).How Did You Test This Change
Unit tests:
KeyBuilderTest(3 new tests demonstrating V1 collision and V2 correctness).