-
Notifications
You must be signed in to change notification settings - Fork 368
[issue 447] double check message size when client enable compress #806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pgier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just had one in-line suggestion.
|
Hello, I think this problem may be resolved in #805 . |
update: "a short-circuit and will work here" Co-authored-by: Paul Gier <[email protected]>
pulsar/producer_partition.go
Outdated
|
|
||
| // if msg is too large | ||
| if len(payload) > int(p._getConn().GetMaxMessageSize()) { | ||
| if len(payload) > int(p._getConn().GetMaxMessageSize()) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that in this PR we do the compression twice when sending the message. The batch builder will do the compression here: https://github.com/apache/pulsar-client-go/blob/master/pulsar/internal/commands.go#L251
Could we move the compression from the batch builder to here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this modification just an translation the implement of https://github.com/apache/pulsar/blob/782132561ac9fc8430ae3ef12913999e5871d3d2/pulsar-client-cpp/lib/ProducerImpl.cc#L431.
It indeed do compress twice.
// Wire format
// [TOTAL_SIZE] [CMD_SIZE][CMD] [MAGIC_NUMBER][CHECKSUM] [PAYLOAD]
// |
// compressed or uncompressed {[METADATA_SIZE_0] [METADATA_0] [PAYLOAD_0]} ...
Acording to the wire format above, SDK cannot compress messages one by one but should compress the whole batchs together.
Another way to avoid 'twice-compress', I think is flushing batchs immediately before and after add big message to batchBuilder.
|
Is it possible to add some tests to verify it? |
Hi @Gleiphir2769, according to the implement of Java-Client, it should also check 'encryptedPayload' not only the payload in 'ProducerMessage'. |
You are right. In the Java Client it checks "encryptedPayload" in batching. But Java Client only checks the "encryptedPayload" before sending when batching enabled, which means it will not check |

Fixes #447
Motivation
Try to fix issue #447.
Modifications
Compress the payload when the payload is too bigger, and check whever the 'compressed payload' is still bigger than expected.