Skip to content

[ISSUE #9633] Enable retry topic V2 by default to prevent name collision#10565

Open
wang-jiahua wants to merge 1 commit into
apache:developfrom
wang-jiahua:fix/enable-retry-topic-v2-by-default
Open

[ISSUE #9633] Enable retry topic V2 by default to prevent name collision#10565
wang-jiahua wants to merge 1 commit into
apache:developfrom
wang-jiahua:fix/enable-retry-topic-v2-by-default

Conversation

@wang-jiahua

Copy link
Copy Markdown
Contributor

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 changes enableRetryTopicV2 default from false to true.

Existing V1 retry topics are still readable because retrieveMessageFromPopRetryTopicV1 remains true (backward compatible).

How Did You Test This Change

Unit tests: KeyBuilderTest (3 new tests demonstrating V1 collision and V2 correctness).

Copilot AI review requested due to automatic review settings July 1, 2026 03:58

Copilot 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.

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.enableRetryTopicV2 default from false to true.
  • 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.

Comment thread common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java Outdated

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

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

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: retrieveMessageFromPopRetryTopicV1 remains true, so existing V1 retry topics are still readable during and after upgrade.
  • [Info] Tests are well-structured: testV1CollisionExample demonstrates the bug, testV2NoCollision proves the fix, testDefaultEnableRetryTopicV2IsTrue locks 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
@wang-jiahua wang-jiahua force-pushed the fix/enable-retry-topic-v2-by-default branch from 8ff7c16 to 743e72f Compare July 1, 2026 05:46
@qianye1001

Copy link
Copy Markdown
Contributor

I don't think we should enable retry topic V2 by default in this PR yet.

Keeping retrieveMessageFromPopRetryTopicV1=true only proves that the new version can still read existing V1 retry topics. It does not fully validate a graceful upgrade path from V1 to V2, especially for rolling upgrades or mixed-version / mixed-config clusters where some brokers may still produce or consume retry messages using the V1 naming rule while others switch to V2.

Before changing the default, we should have explicit upgrade compatibility verification covering the V1 -> V2 transition, or keep enableRetryTopicV2 disabled by default and make the migration opt-in/documented.

@wang-jiahua

Copy link
Copy Markdown
Contributor Author

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:

  1. Close this PR — if the V2 migration should be handled differently (e.g., per-topic migration, or a deprecation timeline)
  2. Add a deprecation warning — keep V1 as default but log a WARN when a collision is detected, guiding users to migrate to V2

Which approach do you prefer? Or should I close this PR entirely?

@RockteMQ-AI

Copy link
Copy Markdown
Contributor

Review by github-manager-bot (Re-review after new commit)

Summary

Re-reviewed after commit 743e72f (2026-07-01T05:46Z). Changes enableRetryTopicV2 default from false to true.

Assessment: ✅ Looks Good

  • Correctness — V2 uses + separator which is not allowed in topic/group names, eliminating the V1 naming collision where group="A_B", topic="C" and group="A", topic="B_C" both produce %RETRY%A_B_C.
  • Backward compatibilityretrieveMessageFromPopRetryTopicV1 remains true, so existing V1 retry topics are still readable during transition.
  • Default change impact — New retry topics will use V2 naming. Existing V1 retry topics continue to work. This is the correct approach for fixing the collision without breaking existing deployments.
  • Tests — Three new tests:
    • testV1CollisionExample — Demonstrates the collision problem
    • testV2NoCollision — Verifies V2 resolves it
    • testDefaultEnableRetryTopicV2IsTrue — Guards against accidental default regression

Clean, well-scoped change with appropriate test coverage.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

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 (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

@qianye1001

Copy link
Copy Markdown
Contributor

建议 close

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] V1 retry topic name collisions can cause cross-topic consumption and message mix-up

4 participants