poorbarcode commented on code in PR #24061:
URL: https://github.com/apache/pulsar/pull/24061#discussion_r1984395407


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java:
##########
@@ -162,13 +162,11 @@ protected ByteBuf 
getCompressedBatchMetadataAndPayload(boolean clientOperation)
             } catch (Throwable th) {
                 // serializing batch message can corrupt the index of message 
and batch-message. Reset the index so,
                 // next iteration doesn't send corrupt message to broker.
-                for (int j = 0; j <= i; j++) {
-                    MessageImpl<?> previousMsg = messages.get(j);
-                    previousMsg.getDataBuffer().resetReaderIndex();
-                }

Review Comment:
   I described this in the Motivation section
   
   > (Highlight): BTW, since {msg-payload-1} has been read out at the first 
flushing, the second one will be empty, so the final data is [{batch-metadata}, 
{msg-payload-1},{single-msg-metadata-1}, {empty}, {single-msg-metadata-2}, 
{msg-payload-2}]
   
   The message-payload will be read again once the previous Send-Command 
building fails; it needs to be reset after a failed Send-Command building.
   
   I reset the message payload after reading it, which is a simple way to fix 
the issue of reading an empty payload. Another solution is as follows, which is 
more safe:
   - records `message-payload.readerIndex` when messages are added
   - only reset `message-payload` when failed building a Send-Command
   
   Please show your view that prefer which soltion



-- 
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