[
https://issues.apache.org/jira/browse/KAFKA-20750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shivsundar R reassigned KAFKA-20750:
------------------------------------
Assignee: Shivsundar R
> 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
> Assignee: Shivsundar R
> Priority: Major
>
> 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)