[Issue 1534] Preserve batch size in transactional acknowledgments - #1535
Open
Ebispongebob wants to merge 1 commit into
Open
Ebispongebob wants to merge 1 commit into
Ebispongebob wants to merge 1 commit into
Conversation
Fixes apache#1534 Signed-off-by: 魏睿韬 <weiruitao@sofunny.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1534
Motivation
A Shared consumer can stop receiving batched messages even though its transactions commit successfully. The Go client drops the producer batch size when converting a completed batch acknowledgment to an entry-level ID, then omits
MessageIdData.BatchSizefrom the transaction ACK. Pulsar 4.0.3 therefore decrements the consumer's unacked count by one instead of the number of messages in the batch. The discrepancy accumulates until the broker blocks dispatch.The issue includes a self-contained reproduction using the unmodified v0.21.0 client. With a broker unacked limit of 20 and three messages per producer batch, the 11th batch cannot be received after the previous ten transactions committed successfully.
Modifications
batchIdx=-1), so ordinary ACK grouping does not reinterpret it as a partial batch ACK.BatchSizefield for transaction ACKs when the size is positive. Non-batched messages retain their existing wire behavior.TestTxn_BatchAckUnackedMessages, using explicit producer flushes and broker stats to verify delivery continues and unacked/backlog return to zero. Cover batched and non-batched messages, single-message batches, ordinary ACKs, batch-index ACKs, abort/redelivery, and separate transactions within one producer batch.Verifying this change
Local validation against official master
61d7a95e66cddf329adc6d925a8bd60ccd26eda5plus this patch:TestTxn_BatchAckUnackedMessagessubtests against Pulsar 4.0.3 standalone withtransactionCoordinatorEnabled=true,acknowledgmentAtBatchIndexLevelEnabled=true, andmaxUnackedMessagesPerConsumer=20.make lint(golangci-lint v2.12.2, 0 issues),go vet ./pulsar, andgit diff --check.Run the new regression with a transaction-enabled broker at
localhost:6650and its admin endpoint atlocalhost:8080:Enable broker-side batch-index acknowledgment for the batch-index subtests. The test does not change broker configuration. A low unacked limit reproduces the dispatch stall quickly; with the default limit, the final broker counter assertions still detect the accounting leak.
Does this pull request potentially affect one of the following parts:
BatchSizefield, and transaction batch-index ACK sets identify only the current index. No new fields or command types are introduced.Documentation