Skip to content

fix(broker): stop overwriting batch ack uniq key with single ack key in appendAck - #11142

Open
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/batch-ack-unique-key-overwrite
Open

zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/batch-ack-unique-key-overwrite

Conversation

@zjncs

@zjncs zjncs commented Sep 11, 2026

Copy link
Copy Markdown

Motivation

appendAck set PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX correctly per ack type (genBatchAckUniqueId for BatchAckMsg, genAckUniqueId otherwise), but a later unconditional put overwrote it with genAckUniqueId for every ack. Batch acks therefore landed on the revive topic with a bogus uniq key: the offset segment was the -1 sentinel the batch path assigns, and the tag segment was ack instead of bAck, so every batch ack of a pop produced the same non-unique client id and tracing by uniq key was impossible.

The buffered path in PopBufferMergeService already writes the batch uniq key without overwriting it.

Modifications

Drop the stray put so the per-type key set just above survives.

Verification

Fail-before (new test, run against the unpatched code):

AckMessageProcessorTest#testBatchAck_appendAck_BatchUniqKeyKept
expected: "FooBar@0@[101]@DEFAULT_CONSUMER@1666860736757@bAck"
 but was: "FooBar@0@-1@DEFAULT_CONSUMER@1666860736757@broker-a@ack"

Pass-after:

Tests run: 9, Failures: 0, Errors: 0, Skipped: 0 -- AckMessageProcessorTest

…in appendAck

appendAck set PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX correctly per ack
type (genBatchAckUniqueId for BatchAckMsg, genAckUniqueId otherwise),
but a later unconditional put overwrote it with genAckUniqueId for
every ack. Batch acks therefore landed on the revive topic with a bogus
uniq key: the offset segment was the -1 sentinel the batch path assigns
and the tag segment was ACK instead of BATCH_ACK, so every batch ack of
a pop produced the same non-unique client id and tracing by uniq key
was impossible.

The buffered path in PopBufferMergeService already writes the batch
uniq key without overwriting it. Drop the stray put so the per-type key
set just above survives.
Copilot AI lite review requested due to automatic review settings September 11, 2026 07:12

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 a bug where appendAck was overwriting the batch ack unique key with the single ack key. Removes the erroneous overwrite line. Test uses ArgumentCaptor to verify the correct key is retained.

LGTM — correct fix with proper test verification.


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.

3 participants