confluentinc / librdkafka

The Apache Kafka C/C++ library
Other
284 stars 3.15k forks source link

MSG_SIZE_TOO_LARGE error text points at broker when in reality the issue is in producer configuration, also fishy configuration mismatch with documentation #3125

Open MikkelHJuul opened 4 years ago

MikkelHJuul commented 4 years ago

Description

Poor error text when producing messages, fails on MSG_SIZE_TOO_LARGE. Description points toward broker, when it is a client/producer error. The apache-kafka documentation for the kafka producer does not even include the fixing configuration: message.max.bytes. (The fix in the code for this issue is to use configuration 'message.max.bytes': <int greater than bytes length of message to send>)

How to reproduce

In python. Using confluent_kafka==1.5.0.

Producer({'bootstrap_servers': <>}).produce('some-topic', <too_large_message>)

LOG:

cimpl.KafkaException: KafkaError{code=MSG_SIZE_TOO_LARGE,val=10,str="Unable to produce message: Broker: Message size too large"}

Checklist

Please provide the following information:

hackery commented 3 years ago

I'd agree with this, message.max.bytes is listed in the Kafka documentation only as a broker property, not producer config. The producer property relating to limiting the request is max.request.size. (It's bad enough that the Kafka docs conflate the meanings of message/record with message batch and request sizes...)

Added now as #3246

alessio-b2c2 commented 2 years ago

Also, it seems to me that the producer checks the uncompressed message size before sending, while the broker checks the compressed message size.

fboranek commented 1 year ago

Also, it seems to me that the producer checks the uncompressed message size before sending, while the broker checks the compressed message size.

You are right. The comprimation is applied on whole batch, so testing occurs on uncompromised message. When using compression it's hard to figure out the right setting for producer to what is set on broker.

The message should be less confusing.

sean-hernon commented 1 year ago

Also confusing: the on_delivery callback configured in the Producer is never called, even though from the error it appears that the message was rejected by the broker.

It can be observed that the on_delivery is called when message.max.bytes in the Producer config is set to some value greater than that which the broker allows (since the message is now sent by the producer and rejected by the broker).