Eric Chang created KAFKA-21485:
----------------------------------

             Summary: KafkaShareConsumer#commitSync(Duration) can block longer 
than the given timeout
                 Key: KAFKA-21485
                 URL: https://issues.apache.org/jira/browse/KAFKA-21485
             Project: Kafka
          Issue Type: Bug
          Components: clients, consumer
    Affects Versions: 4.4.0, 4.3.0, 4.2.0, 4.1.0, 4.0.0
            Reporter: Eric Chang
            Assignee: Eric Chang


{{ShareConsumerImpl#commitSync(Duration)}} waits for the result with 
{{ConsumerUtils.getResult(commitFuture)}}. This calls {{Future#get()}} without 
a timeout.

The application thread returns only when the background thread completes the 
future. This happens when the response arrives, when the request expires in 
{{ShareConsumeRequestManager}}, or when {{CompletableEventReaper}} expires the 
event. The reaper runs once per loop of the background thread, and one loop can 
take up to 5 seconds. So {{commitSync(Duration)}} can return much later than 
the given timeout. If the background thread is stuck, it does not return.

{{AsyncKafkaConsumer#commitSync}} uses {{ConsumerUtils.getResult(commitFuture, 
requestTimer)}}. The share consumer should do the same.

Note: on timeout, {{commitSync}} now either throws {{TimeoutException}} 
(reaper) or returns a map with {{TimeoutException}} for each partition (request 
manager). The javadoc does not say which one is expected.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to