Gleiphir2769 commented on PR #16797:
URL: https://github.com/apache/pulsar/pull/16797#issuecomment-1203469646
> > requested changes
>
> Hi, thanks for your review. The problem for `TotalChunkMsgSize ` will be
caused by the message with incorrect metadata, which is caused by the incorrect
implementation of the producer client. So I think it should check each chunk
because it's not necessarily only the last chunk will cause the problem.
> out-of-order chunks would not make the total bytes greater than the
`total_chunk_msg_size`, we should only check chunk id here.
>
> If the total size of `chunkedMsgBuffer` was greater than the
`total_chunk_msg_size` field, which is set by producer, it might be caused by
the corrupted message metadata or wrong implementations of producer. (e.g.
there are two chunked messages with the same UUID and those chunks are mixed)
>
> In this case, we should not check the size here. Instead, if you tend to
validate whether the `total_chunk_msg_size` is right, you should check it when
the chunked message is complete.
>
> ```java
> if (msgMetadata.getChunkId() != (msgMetadata.getNumChunksFromMsg()
- 1)) {
> /* ... */
> return null;
> }
>
> if (chunkedMsgCtx.chunkedMsgBuffer.readableBytes() !=
msgMetadata.getTotalChunkMsgSize()) {
> log.error("Received a chunked message whose size is {} while
the total_chunk_msg_size field is {}",
> chunkedMsgCtx.chunkedMsgBuffer.readableBytes(),
msgMetadata.getTotalChunkMsgSize());
> chunkedMsgCtx.chunkedMsgBuffer.release();
> compressedPayload.release();
> // TODO: we need to remove the current chunkedMsgCtx, maybe we
should throw an exception here?
> return null;
> }
> ```
>
> If the total
Hi, thanks for your review. The problem for TotalChunkMsgSize will be caused
by the message with incorrect metadata, which is caused by the incorrect
implementation of the producer client. So I think it should check each chunk
because it's not necessarily only the last chunk will cause the problem.
--
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]