0xffff-zhiyan opened a new pull request, #20356: URL: https://github.com/apache/kafka/pull/20356
JMX metrics RequestHandlerAvgIdlePercent reports a value close to 2 in combined kraft mode but it's expected to be b/w 0 and 1. This is an issue with kraft combined mode specifically because both `controller` + `broker` are using the same Meter object in combined mode, defined in `RequestThreadIdleMeter#requestThreadIdleMeter`, but the controller and broker are using separate `KafkaRequestHandlerPool` objects, where each object's `threadPoolSize == KafkaConfig.numIoThreads`. This means when calculating idle time, each pool divides by its own `numIoThreads`value before reporting to the shared meter and `Meter` calculates the final result by accumulating all the values reported by all threads. However, since there are actually `2 × numIoThreads` total threads contributing to the metric, the denominator should be doubled to get the correct average. Changes: 1. When creating `dataPlaneRequestHandlerPool`, we pass `KafkaConfig.isKRaftCombinedMode`; in combined mode the pool adjusts the idle calculation (dividing by `2 * totalHandlerThreads`), using the total thread count from both pools as the denominator 2. When resizing threadpool, update the pool size each time a thread is created/destroyed to ensure the size is up to date 3. add a unit test mocking the combined mode where broker & controller share the `Meter` and use separate `RequestHandlerPool` 4. add unit test for threadpool resizing https://issues.apache.org/jira/browse/KAFKA-19606 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org