-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][client] Fix cannot retry chunk messages and send to DLQ #21048
Merged
Conversation
This file contains 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
RobertIndie
requested review from
BewareMyPower,
poorbarcode,
liangyepianzhou and
mattisonchao
August 23, 2023 04:41
poorbarcode
reviewed
Aug 30, 2023
pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java
Outdated
Show resolved
Hide resolved
poorbarcode
reviewed
Aug 30, 2023
pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java
Outdated
Show resolved
Hide resolved
Hi, @poorbarcode , I have added the timeout of receive opeartion for the test. PTAL again. Thanks. |
poorbarcode
reviewed
Aug 30, 2023
pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/UnAckedMessageTracker.java
Show resolved
Hide resolved
codelipenghui
approved these changes
Aug 30, 2023
pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java
Outdated
Show resolved
Hide resolved
poorbarcode
approved these changes
Aug 30, 2023
liangyepianzhou
approved these changes
Aug 30, 2023
RobertIndie
added a commit
that referenced
this pull request
Aug 31, 2023
(cherry picked from commit 99e3fea)
RobertIndie
added a commit
that referenced
this pull request
Aug 31, 2023
(cherry picked from commit 99e3fea)
RobertIndie
added a commit
that referenced
this pull request
Sep 5, 2023
(cherry picked from commit 99e3fea)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/client
cherry-picked/branch-2.11
cherry-picked/branch-3.0
cherry-picked/branch-3.1
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/2.11.3
release/3.0.2
release/3.1.1
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 #20934
Motivation
If the consumer receives a chunked message, it currently couldn't retry it or send it to the DLQ. It will throw an exception like this:
This is because we don't enable the chunking for the retry producer and the DLQ producer in the consumer.
This PR enables the chunking feature for retry and DLQ producers. However, we cannot enable both chunking and batching simultaneously. Therefore, the trade-off of this change is that we have to turn off the batching for the DLQ producer, while the retry producer has already done so. This is acceptable because the DLQ producer usually has low traffic. It does not have a significant impact on the performance.
This PR also addresses the following two issues:
Issue A: Consumers cannot redeliver chunked messages
When the consumer attempts to redeliver a chunked message, the message ID is reconstructed in
discardBatch
, which causes this message ID to lose the chunk information. The comparison in theunAckedChunkedMessageIdSequenceMap
will fail. The consumer will never be able to redeliver chunked messages.We should not reconstruct the chunked message ID in
discardBatch
. The chunk message ID does not contain any batch information.Issue B: The chunked message cannot be resent
When the producer resends the chunked message, the chunk id in the message metadata of all subsequent chunks will be set to the last chunk id.
The root cause is that the producer shares the same MessageMetadata for all chunks in a chunked message.
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
Lines 696 to 700 in 4634311
Therefore, when
op.rePopulate
is called, the chunk id infinalMsgMetadata
is pointed to the last chunk. Suppose we have a large message with 3 chunks. The producer may end up sending all 3 messages with the same chunk id3
. The consumer will treat these messages as corrupted and ignore them, preventing it from receiving any of these messages.Modification
testDeadLetterTopic
.Verifying this change
This change added tests.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: