BewareMyPower commented on issue #6806: URL: https://github.com/apache/pulsar/issues/6806#issuecomment-618794964
The problem may be the strange value (538973717) of `readIdx_` 。Could you provide the `payload` info of each frame? Following is the lifetime of `payload` (if I don't miss something): The payload first constructed in `ClientConnection::processIncomingBuffer()`: ```c++ SharedBuffer payload = SharedBuffer::copy(incomingBuffer_.data(), payloadSize); incomingBuffer_.consume(payloadSize); // payload.readIdx_ should be 0 here handleIncomingMessage(incomingCmd_.message(), isChecksumValid, msgMetadata, payload); ``` Then it comes to `ClientConnection::handleIncomingMessage()`, `payload` was passed to `consumer->messageReceived()` without any changes. In `ConsumerImpl::messageReceived`, `payload` may be modified in `decryptMessageIfNeeded()` and `uncompressMessageIfNeeded()`, while the previous may do nothing if encryption was not enabled. Then the payload was passed to the constructor of `Message` as `m.impl_->payload`, and next `m` was passed to `receiveIndividualMessagesFromBatch`: ```c++ Message m(msg, metadata, payload, partitionIndex_); m.impl_->cnx_ = cnx.get(); m.impl_->setTopicName(topic_); m.impl_->setRedeliveryCount(msg.redelivery_count()); unsigned int numOfMessageReceived = 1; if (metadata.has_num_messages_in_batch()) { Lock lock(mutex_); // m.impl_->payload.readIdx_ should be 0 here numOfMessageReceived = receiveIndividualMessagesFromBatch(cnx, m, msg.redelivery_count()); ``` And next: ```c++ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx, Message& batchedMessage, int redeliveryCount) { unsigned int batchSize = batchedMessage.impl_->metadata.num_messages_in_batch(); batchAcknowledgementTracker_.receivedMessage(batchedMessage); // it doesn't modify batchedMessage int skippedMessages = 0; for (int i = 0; i < batchSize; i++) { // Now, batchedMessage.impl_->payload.readIdx_ becomes 538973717 Message msg = Commands::deSerializeSingleMessageInBatch(batchedMessage, i); ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org