You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Shivsundar R (Jira)" <ji...@apache.org> on 2026/06/30 16:28:00 UTC
[jira] [Created] (KAFKA-20750) Divide-by-zero error in PollIdleRatio metric during sub-millisecond poll intervals.
Shivsundar R created KAFKA-20750:
------------------------------------
Summary: Divide-by-zero error in PollIdleRatio metric during sub-millisecond poll intervals.
Key: KAFKA-20750
URL: https://issues.apache.org/jira/browse/KAFKA-20750
Project: Kafka
Issue Type: Improvement
Reporter: Shivsundar R
In KafkaConsumerMetrics (and KafkaShareConsumerMetrics), we calculate pollIdleRatio the following way.
{code:java}
public void recordPollStart(long pollStartMs) {
this.pollStartMs = pollStartMs;
this.timeSinceLastPollMs = lastPollMs != 0L ? pollStartMs - lastPollMs : 0;
this.timeBetweenPollSensor.record(timeSinceLastPollMs);
this.lastPollMs = pollStartMs;
}
public void recordPollEnd(long pollEndMs) {
long pollTimeMs = pollEndMs - pollStartMs;
double pollIdleRatio = pollTimeMs * 1.0 / (pollTimeMs + timeSinceLastPollMs);
this.pollIdleSensor.record(pollIdleRatio);
} {code}
So in cases of high throughput and fast polls, there is a chance of getting sub-millisecond poll processing time and the next poll starting in the same millisecond (Observed in local broker testing) giving a zero in the denominator.
In this case, we see a NaN as the metric value observed. This should instead be a 0, needs a simple check for 0 in the denominator.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)