[
https://issues.apache.org/jira/browse/KAFKA-21031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
TengYao Chi updated KAFKA-21031:
--------------------------------
Description:
Code inspection found that a group heartbeat manager can return a zero poll
timeout
while a heartbeat request is still in flight.
When the heartbeat timer expires,
\{{HeartbeatRequestState.timeToNextHeartbeatMs()}}
falls through to the remaining retry backoff. That backoff is measured from the
last
response, so it is normally already 0. The heartbeat managers propagate this
value
through \{{poll()}} and \{{maximumTimeToWait()}}, so the network and
application threads
busy loop until the response arrives or the request times out.
This happens after the member has joined (typically \{{STABLE}}). The client has
learned the heartbeat interval and sent a later heartbeat, but the response
does not
arrive before that interval elapses. The heartbeat timer expires while the
request
remains in flight, and the request has not yet reached \{{request.timeout.ms}}.
The fix is to return the initial retry backoff in this state. It applies to the
consumer, share and streams heartbeat managers because they share
{\{HeartbeatRequestState}}.
Out of scope:
* The first heartbeat while joining is covered by KAFKA-19804, which starts the
heartbeat timer with \{{request.timeout.ms}} as the interval.
* \{{retry.backoff.ms=0}} still results in a zero wait. This is tracked
consistently
across the request managers in KAFKA-21049.
was:
Code inspection found that a group heartbeat manager can return a zero poll
timeout
while a heartbeat request is still in flight.
When the heartbeat timer expires,
\{{HeartbeatRequestState.timeToNextHeartbeatMs()}}
falls through to the remaining retry backoff, which is normally 0. The heartbeat
managers propagate this value through their poll wait times, so the consumer can
repeatedly poll without blocking until the request completes.
The timer can expire while a request is in flight in two phases:
* *Joining:* the first heartbeat has been sent, but no successful response has
arrived, so the heartbeat interval is still 0 and its timer is already
expired.
* *After joining (typically \{{STABLE}}):* the client has learned the heartbeat
interval and sent a later heartbeat, but its response does not arrive before
that
interval elapses. The heartbeat timer expires while the request remains in
flight;
the request itself has not yet reached \{{request.timeout.ms}}.
Return the initial retry backoff, floored at 1 ms, in this state. Unit tests
cover
both situations and verify that the positive wait reaches the heartbeat
manager's
poll paths.
> Another busy loop happens while a heartbeat is in flight and the heartbeat
> timer is expired
> -------------------------------------------------------------------------------------------
>
> Key: KAFKA-21031
> URL: https://issues.apache.org/jira/browse/KAFKA-21031
> Project: Kafka
> Issue Type: Bug
> Components: clients, consumer
> Reporter: Eric Chang
> Assignee: Eric Chang
> Priority: Major
> Fix For: 4.5.0
>
>
> Code inspection found that a group heartbeat manager can return a zero poll
> timeout
> while a heartbeat request is still in flight.
> When the heartbeat timer expires,
> \{{HeartbeatRequestState.timeToNextHeartbeatMs()}}
> falls through to the remaining retry backoff. That backoff is measured from
> the last
> response, so it is normally already 0. The heartbeat managers propagate this
> value
> through \{{poll()}} and \{{maximumTimeToWait()}}, so the network and
> application threads
> busy loop until the response arrives or the request times out.
> This happens after the member has joined (typically \{{STABLE}}). The client
> has
> learned the heartbeat interval and sent a later heartbeat, but the response
> does not
> arrive before that interval elapses. The heartbeat timer expires while the
> request
> remains in flight, and the request has not yet reached
> \{{request.timeout.ms}}.
> The fix is to return the initial retry backoff in this state. It applies to
> the
> consumer, share and streams heartbeat managers because they share
> {\{HeartbeatRequestState}}.
> Out of scope:
> * The first heartbeat while joining is covered by KAFKA-19804, which starts
> the
> heartbeat timer with \{{request.timeout.ms}} as the interval.
> * \{{retry.backoff.ms=0}} still results in a zero wait. This is tracked
> consistently
> across the request managers in KAFKA-21049.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)