heesung-sn commented on code in PR #20948:
URL: https://github.com/apache/pulsar/pull/20948#discussion_r1304854457


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -1449,6 +1450,23 @@ private ByteBuf processMessageChunk(ByteBuf 
compressedPayload, MessageMetadata m
         // discard message if chunk is out-of-order
         if (chunkedMsgCtx == null || chunkedMsgCtx.chunkedMsgBuffer == null
                 || msgMetadata.getChunkId() != 
(chunkedMsgCtx.lastChunkedMessageId + 1)) {
+            // Filter duplicated chunks instead of discard it.
+            if (chunkedMsgCtx == null || msgMetadata.getChunkId() <= 
chunkedMsgCtx.lastChunkedMessageId) {
+                log.warn("[{}] Receive a repeated chunk messageId {}, 
last-chunk-id{}, chunkId = {}",
+                        msgMetadata.getProducerName(), chunkedMsgCtx == null ? 
null
+                                : chunkedMsgCtx.lastChunkedMessageId, msgId, 
msgMetadata.getChunkId());
+                compressedPayload.release();
+                increaseAvailablePermits(cnx);
+                if (chunkedMsgCtx != null) {

Review Comment:
   - can you add some comments for this ack logic for out-of-order messages?
   - It seems to be inefficient to iterate all chunks every time. Can we 
optimize it? I believe all chunk message ids(ledger and entry) for the same 
message should be the same, aren't they? Can't we check the last chunk's 
messageId only?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to