[ 
https://issues.apache.org/jira/browse/KAFKA-4854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zhangzhisheng updated KAFKA-4854:
---------------------------------
    Attachment: image-2023-03-28-15-45-47-783.png

> Producer RecordBatch executes callbacks with `null` provided for metadata if 
> an exception is encountered
> --------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-4854
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4854
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>    Affects Versions: 0.10.1.1
>            Reporter: Robert Quinlivan
>            Assignee: Ewen Cheslack-Postava
>            Priority: Minor
>         Attachments: image-2023-03-28-15-45-47-783.png
>
>
> When using a user-provided callback with the producer, the `RecordBatch` 
> executes the callbacks with a null metadata argument if an exception was 
> encountered. For monitoring and debugging purposes, I would prefer if the 
> metadata were provided, perhaps optionally. For example, it would be useful 
> to know the size of the serialized payload and the offset so these values 
> could appear in application logs.
> To be entirely clear, the piece of code I am considering is in 
> `org.apache.kafka.clients.producer.internals.RecordBatch#done`:
> ```java
>         // execute callbacks
>         for (Thunk thunk : thunks) {
>             try {
>                 if (exception == null) {
>                     RecordMetadata metadata = thunk.future.value();
>                     thunk.callback.onCompletion(metadata, null);
>                 } else {
>                     thunk.callback.onCompletion(null, exception);
>                 }
>             } catch (Exception e) {
>                 log.error("Error executing user-provided callback on message 
> for topic-partition '{}'", topicPartition, e);
>             }
>         }
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to