Repository navigation
[Issue 456] Support chunking for big messages. - #805
Conversation
zzzming
left a comment
There was a problem hiding this comment.
Based on Java implementation, ConsumerImpl.java, Chunking also requires changes at the consumer side to be able to assembly chunks into the original message. Are you going to add support on the consumer side?
The consumer side implement is already planned. It will be commited in another PR. |
…g of sequenceID generate; fix the bug where batch messages are compressed twice; add internal error handle, fix inaccurate PublishErrorsMsgTooLarge metric; fix the incorrect producer queueFullBlock
bf39e92 to
0456630
Compare
…ecause it's no need
Hi, the consumer side is implemented here. Looking forward to your review. @zzzming |
…atchIDX to pass test. Add the lisence headers to timewheel.go/timewheel_test.go/message_chunking_test.go
…e. 2. Add the unit test for chunk size. 3. fix some other bugs.
|
This PR will be possible to fix this issue #447. |
|
/pulsarbot run-failure-checks |
nodece
left a comment
There was a problem hiding this comment.
Your PR seems to have made improvements unrelated to chunking, if so, I suggest you make a new PR to improve.
|
|
||
| if mid.consumer != nil { | ||
| return mid.Ack() | ||
| if err := c.checkMsgIDPartition(msgID); err != nil { |
There was a problem hiding this comment.
Missed covert the msgID from the MessageID to the trackingMessageID type, I'm not sure if we need this.
Why not use messageID(), what did I miss?
There was a problem hiding this comment.
trackingMessageID does not records chunking infomation.
For example, Ack() a big message need to ack all the chunks of it. Using trackingMessageID can not figure out which chunk (messageId) need to be ack.
trackingMessageID is designed to tracking batch messages so it shoud not be the messageId type accepted by the method exposed by partitionConsumer. I think the better way would be to accept MessageID as the messageId type in partitionConsumer methods. However, only the necessary interfaces have been modified (Ack, NAck and Seed) for the least changes
| } | ||
| msgSize := uint32(len(payload)) | ||
| return bc.numMessages+1 <= bc.maxMessages && bc.buffer.ReadableBytes()+msgSize <= uint32(bc.maxBatchSize) | ||
| expectedSize := bc.buffer.ReadableBytes() + msgSize |
There was a problem hiding this comment.
Please revert this code(170-174).
There was a problem hiding this comment.
L171 compared the bc.buffer.ReadableBytes() + msgSize with bc.maxMessageSize and the original code does not.
It used to make sure that one batch size does not exceed the maxMessageSize. It's a part of correctly calculation whether the message is too large.
By the way, the compare code is too long to be inline.
There was a problem hiding this comment.
Good catch, but using inline looks like more clear, so like:
return bc.numMessages+1 <= bc.maxMessages && expectedSize <= uint32(bc.maxBatchSize) && expectedSize <= bc.maxMessageSize
There was a problem hiding this comment.
@nodece This PR introduces the maxMessageSize. I think these changes should be related to this PR.
There was a problem hiding this comment.
Good catch, but using inline looks like more clear, so like:
return bc.numMessages+1 <= bc.maxMessages && expectedSize <= uint32(bc.maxBatchSize) && expectedSize <= bc.maxMessageSize
Done, thx.
|
/pulsarbot run-failure-checks |
|
Does the chunking work on shared subscription introduced in Pulsar 2.11? |
Hi @maraiskruger1980, This PR is finished when pulsar 2.11 has not been released. So it doesn't support shared subscription chunking. I think I can take some time on it. Welcome to follow the progress. |
|
That will be great if it can support shared subscription |
Hi @maraiskruger1980. After I checked, it does no limit in consumer when subscription is |
…tion tests (#1511) Master Issue: apache/pulsar#21048 Related Issue: #805 ### Motivation In the Java SDK (PR apache/pulsar#21048), the DLQ/RLQ producers are hardcoded with `enableBatching(false).enableChunking(true)` to ensure large chunked messages can be forwarded to DLQ/RLQ topics successfully. However, in the Go SDK, the DLQ/RLQ producers are created using `DLQPolicy.ProducerOptions`, which defaults to a zero-value `ProducerOptions{}` (i.e., `EnableChunking: false`, `DisableBatching: false`). This means that if a producer sends a chunked message larger than the broker's `maxMessageSize`, and the consumer is configured with DLQ/RLQ, the DLQ/RLQ producer will fail to forward the message because it cannot chunk it. We considered automatically enabling chunking in the DLQ/RLQ producers when the user has not explicitly configured `ProducerOptions`. However, since `EnableChunking` and `DisableBatching` are both `bool` fields with a zero value of `false`, there is no way to distinguish between: - The user intentionally setting them to `false` (meaning "I don't want chunking") - The user not configuring them at all (meaning "I didn't think about it") Automatically overriding these values would break backward compatibility for users who explicitly set `EnableChunking: false`. Therefore, instead of changing the default behavior, we add documentation to guide users to enable chunking in `DLQPolicy.ProducerOptions` when using chunked messages with DLQ/RLQ. ### Modifications - Added a note to the `EnableChunking` field documentation in `ProducerOptions` (`producer.go`) explaining that when chunking is enabled and the consumer uses DLQ/RLQ, it is recommended to also enable chunking in `DLQPolicy.ProducerOptions`. - Added a note to the `DLQPolicy.ProducerOptions` field documentation (`consumer.go`) explaining that if the messages being consumed were produced with chunking enabled, it is recommended to also enable chunking here. This helps in decoupled producer/consumer scenarios where the consumer developer may not be aware of the producer's chunking configuration. - Added `TestChunkReconsumeLater` integration test to verify chunked messages (5MB, exceeding broker maxMessageSize) can be sent to the retry topic via `ReconsumeLater` and routed to DLQ after exceeding max retries, when `DLQPolicy.ProducerOptions` has chunking enabled. - Added `TestChunkDLQWithNack` integration test to verify chunked messages (5MB) are routed to DLQ after exceeding max redelivery count via `Nack`, when `DLQPolicy.ProducerOptions` has chunking enabled. ### Verifying this change This change added tests and can be verified as follows: - Added `TestChunkReconsumeLater`: sends a 5MB chunked message, verifies it flows through retry topic via `ReconsumeLater` and eventually lands in DLQ after exceeding `MaxDeliveries`. - Added `TestChunkDLQWithNack`: sends a 5MB chunked message, verifies it is routed to DLQ after exceeding max redelivery count via `Nack`, with original properties preserved. Both tests use payloads larger than broker `maxMessageSize` (~1MB) to ensure that DLQ/RLQ producers **must** have chunking enabled to successfully forward messages. Without chunking enabled in `DLQPolicy.ProducerOptions`, these tests would timeout.
Contribution Checklist
Master Issue: #456
Motivation
Make pulsar go client support chunking to produce/consume big messages. The earlier implementation (#717) didn't take into account many details, so I decided to reimplement it.
Modifications
internalSingleSendto send message without batch because batch message will not be received by chunk.BlockIfQueueFullcheck frominternalSendAsynctointernalSend(canAddQueue) to ensure the normal block in chunking.chunkedMsgCtxMapto store chunked messages meta and data.Verifying this change
This change added tests and can be verified as follows:
TestProducerChunkingto verify send big message by chunking.message_chunking_testto verify message chunking.Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation