apoorvmittal10 commented on code in PR #18959:
URL: https://github.com/apache/kafka/pull/18959#discussion_r1964534212
##########
core/src/main/java/kafka/server/share/DelayedShareFetch.java:
##########
@@ -120,16 +141,28 @@ public void onComplete() {
try {
LinkedHashMap<TopicIdPartition, Long> topicPartitionData;
// tryComplete did not invoke forceComplete, so we need to check
if we have any partitions to fetch.
- if (partitionsAcquired.isEmpty())
+ if (partitionsAcquired.isEmpty()) {
topicPartitionData = acquirablePartitions();
- // tryComplete invoked forceComplete, so we can use the data from
tryComplete.
- else
+ // The TopicPartitionsAcquireTimeMs metric signifies the
tension when acquiring the locks
+ // for the share partition, hence if no partitions are yet
acquired by tryComplete,
+ // we record the metric here. Do not check if the request has
successfully acquired any
+ // partitions now or not, as then the upper bound of request
timeout shall be recorded
+ // for the metric.
+ updateAcquireElapsedTimeMetric();
+ } else {
+ // tryComplete invoked forceComplete, so we can use the data
from tryComplete.
topicPartitionData = partitionsAcquired;
+ }
if (topicPartitionData.isEmpty()) {
// No locks for share partitions could be acquired, so we
complete the request with an empty response.
- shareFetch.maybeComplete(Collections.emptyMap());
+
shareGroupMetrics.recordTopicPartitionsFetchRatio(shareFetch.groupId(), 0);
+ shareFetch.maybeComplete(Map.of());
return;
+ } else {
+ // Update metric to record acquired to requested partitions.
+ double requestTopicToAcquired = (double)
topicPartitionData.size() / shareFetch.partitionMaxBytes().size();
+
shareGroupMetrics.recordTopicPartitionsFetchRatio(shareFetch.groupId(), (int)
(requestTopicToAcquired * 100));
Review Comment:
I thought about the same, thanks for confirming.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]