Skip to content

[ISSUE #10945] Align POP retry records with result batches - #10946

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/pop-retry-record-index
Open

[ISSUE #10945] Align POP retry records with result batches#10946
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/pop-retry-record-index

Conversation

@Aias00

@Aias00 Aias00 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Aligns the flattened POP consumer-record index with each fetched GetMessageResult. This keeps retry-message recoding associated with the correct result after a preceding multi-message batch.

Fixes #10945.

Test

mvn -pl broker -Dtest=PopConsumerServiceTest#popAsyncRecodeRetryMessagesAfterMultiMessageNormalResultTest test

Signed-off-by: liuhy <liuhongyu@apache.org>

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

Summary

Correct fix for POP retry record index misalignment when a multi-message batch precedes retry messages.

The original code used the loop index i to access both getGetMessageResultList() and getPopConsumerRecordList(), but these lists have different cardinalities when a single GetMessageResult contains multiple messages. The fix correctly introduces a separate popConsumerRecordIndex that advances by getMessageQueueOffset().size() per batch, aligning the record index with the actual message count.

Test coverage is thorough — the new test validates the scenario with a 2-message normal result followed by a 1-message retry result.

LGTM.


Automated review by github-manager-bot

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.54%. Comparing base (293f588) to head (02a38f8).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10946      +/-   ##
=============================================
- Coverage      48.62%   48.54%   -0.09%     
+ Complexity     13692    13670      -22     
=============================================
  Files           1381     1381              
  Lines         101464   101466       +2     
  Branches       13187    13187              
=============================================
- Hits           49337    49255      -82     
- Misses         46142    46202      +60     
- Partials        5985     6009      +24     

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

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

Summary

Fixes an index misalignment bug in PopConsumerService.popAsync() where PopConsumerRecord list indexing was incorrectly using the batch index instead of tracking cumulative message offsets.

The bug: When a GetMessageResult contains multiple messages (batch result), the PopConsumerRecord list has one entry per message (flat list), but the old code used the same loop index i for both lists — causing misalignment after the first batch with >1 message.

The fix:

  • Introduces popConsumerRecordIndex that advances by getMessageResult.getMessageQueueOffset().size() per iteration, correctly tracking the cumulative offset into the flat record list.

Assessment:

  • ✅ Correctness: Precisely fixes the index mismatch. The old code would silently use wrong records after the first multi-message batch.
  • ✅ Tests: popAsyncRecodeRetryMessagesAfterMultiMessageNormalResultTest covers the exact scenario.
  • ✅ Clean helper: getFoundResult(long... offsets) is reusable.

LGTM — good catch on a subtle indexing bug.


Automated review by github-manager-bot

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] POP retry response recoding uses the wrong record after a multi-message batch

3 participants