Skip to content

[ISSUE #10276] Fix PopConsumerService changeInvisibilityDuration losing CK record when visibilityTimeout collision#10277

Open
qianye1001 wants to merge 4 commits intoapache:developfrom
qianye1001:fix/pop-consumer-ck-key-collision
Open

[ISSUE #10276] Fix PopConsumerService changeInvisibilityDuration losing CK record when visibilityTimeout collision#10277
qianye1001 wants to merge 4 commits intoapache:developfrom
qianye1001:fix/pop-consumer-ck-key-collision

Conversation

@qianye1001
Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

In PopConsumerService.changeInvisibilityDuration, the RocksDB key is composed of visibilityTimeout + groupId + topicId + queueId + offset, where visibilityTimeout = popTime + invisibleTime.

When the new CK's changedPopTime + changedInvisibleTime equals the old CK's popTime + invisibleTime, both records produce the same RocksDB key. The current code first writes the new CK (which overwrites the old record at the same key), then deletes using the old CK's key — which inadvertently removes the newly written record, causing the message to never be retried.

Fix: Added a check before the delete operation. If the write was performed and the new CK has the same visibilityTimeout as the old one (same key), the delete is skipped since the write already replaced the old value in place.

How Did You Test This Change?

  • Verified compilation passes successfully
  • Verified no new lint or compilation errors in the modified file
  • Logic analysis confirms correctness for all scenarios:
    1. Keys differ → write new CK + delete old CK (normal path)
    2. Keys same → write overwrites old record, skip delete (fix path)
    3. Group absent (skipWrite) → skip write + delete old CK (unchanged behavior)

…n losing CK record when visibilityTimeout collision
Comment thread broker/src/main/java/org/apache/rocketmq/broker/pop/PopConsumerService.java Outdated
Copy link
Copy Markdown
Member

@lizhimins lizhimins left a comment

Choose a reason for hiding this comment

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

这里和下面合并吧,别取反了

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.87%. Comparing base (5ad6a3e) to head (aa5542c).

Files with missing lines Patch % Lines
...apache/rocketmq/broker/pop/PopConsumerService.java 60.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10277      +/-   ##
=============================================
- Coverage      48.91%   48.87%   -0.05%     
+ Complexity     13455    13438      -17     
=============================================
  Files           1375     1375              
  Lines         100448   100450       +2     
  Branches       12971    12973       +2     
=============================================
- Hits           49137    49092      -45     
- Misses         45308    45345      +37     
- Partials        6003     6013      +10     

☔ View full report in Codecov by Sentry.
📢 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] PopConsumerService changeInvisibilityDuration may lose CK record when visibilityTimeout collision

3 participants