sanghyeok An created KAFKA-21229:
------------------------------------

             Summary: AsyncKafkaConsumer passes null offsets to 
OffsetCommitCallback when an asynchronous commit fails
                 Key: KAFKA-21229
                 URL: https://issues.apache.org/jira/browse/KAFKA-21229
             Project: Kafka
          Issue Type: Bug
            Reporter: sanghyeok An
            Assignee: sanghyeok An


When an asynchronous commit fails in AsyncKafkaConsumer with 
group.protocol=consumer, the user-provided OffsetCommitCallback receives null 
instead of the offsets associated with the request.

Both overloads are affected:
{code:java}
consumer.commitAsync(offsets, callback);
consumer.commitAsync(callback);
{code}
Successful commits pass the request offsets correctly.

*Expected behavior*

The callback should receive the offsets and metadata associated with the 
request, regardless of whether the commit succeeds or fails. The exception 
argument should indicate the failure and its cause.

This is consistent with the documentation for the offsets parameter of 
OffsetCommitCallback.onComplete() and the behavior of the Classic Consumer.

 

*Actual behavior and impact*

When an asynchronous commit fails, the callback is invoked as follows:
{code:java}
callback.onComplete(null, exception); {code}
Applications cannot identify or log the offsets associated with the failed 
request using the callback argument. Error-handling code that accesses the 
offsets map may throw a NullPointerException.
{code:java}
consumer.commitAsync((offsets, exception) -> {
    if (exception != null)
{         offsets.forEach((partition, offset) ->             
recordFailure(partition, offset, exception));     }
}); {code}
This issue concerns the information provided when reporting a failed commit. It 
does not imply that the issue itself causes commit failures or data loss.

 

*Root cause*

AsyncKafkaConsumer.commitAsync() forwards the committedOffsets value received 
by the commit future’s whenComplete handler directly to the user callback.

When the future completes exceptionally, committedOffsets` is `null`. The 
implementation does not fall back to the explicitly supplied request offsets. 
When offsets are omitted, the offsets calculated in the background are not 
separately retained for the failure callback either.



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

Reply via email to