KAFKA-20585 : Share Fetch latency metric incorrectly updated during ShareAcknowledgeResponse#22296
KAFKA-20585 : Share Fetch latency metric incorrectly updated during ShareAcknowledgeResponse#22296muralibasani wants to merge 2 commits into
Conversation
nileshkumar3
left a comment
There was a problem hiding this comment.
Thanks for PR, +1 on the fix.
It looks like there is no dedicated ack latency sensor in ShareFetchMetricsManager today. If ack latency is useful to track, this may be worth a follow-up JIRA rather than reusing fetch metrics.
Also, consider adding a test asserting that fetch-rate/fetch-total do not change after a successful ShareAcknowledge response, to guard against regression.
| metadata.updatePartitionLeadership(partitionsWithUpdatedLeaderInfo, leaderNodes); | ||
| } | ||
|
|
||
| if (acknowledgeRequestState.isProcessed) { |
There was a problem hiding this comment.
- The metrics are being recorded at the end of the response handler, so we would be missing to update the share-fetch-rate and share-fetch-total metrics for responses with top level errors. This is the same pattern in FetchManager as well where we are missing these responses with top level errors. Not sure if this was intended or we should account for these as well. Lianet Magrans could you help take a look at the regular consumer/share-consumer and see what we should do here?
Is this addressed?
There was a problem hiding this comment.
@chia7712 thank you for the review.
I pushed a commit to address this. I also commented in the ticket about this change, if that looks ok.
There was a problem hiding this comment.
@muralibasani For my understanding, if there is only ShareAcknowledge request then will we still record latency? I can see code only in handleShareFetchSuccess now.
There was a problem hiding this comment.
@apoorvmittal10 sorry for delayed reply.
And that's correct. With this change, latency is recorded only in handleShareFetchSuccess, so a ShareAcknowledge-only round trip no longer records latncy. I do not see any dedicated acknowledge-sensor now.
@nileshkumar3 thanks for the review. IMO this was copy pasted by mistake and we ended up with this duplicate in ack method. We might have other metrics in these round trip situations. If you still feel it's worth adding, I will. |
Reg the follow-up jira, I think it makes sense. |
| final ShareFetchResponse response = (ShareFetchResponse) resp.responseBody(); | ||
| final ShareSessionHandler handler = sessionHandler(fetchTarget.id()); | ||
|
|
||
| metricsManager.recordLatency(resp.destination(), resp.requestLatencyMs()); |
There was a problem hiding this comment.
should we move it to finally ?
There was a problem hiding this comment.
moving it to finally will record the metric even if above lines 817 or 818 fail (while getting response and handler), and we don't want that right.
There was a problem hiding this comment.
Given the JIRA intent of capturing top-level errors too, IMO finally is a cleaner fit. Curious what @chia7712 / @apoorvmittal10 think.
IMO, adding a regression test for this issue worths, other metrics may be a follow up. |
| final FetchResponse response = (FetchResponse) resp.responseBody(); | ||
| final FetchSessionHandler handler = sessionHandler(fetchTarget.id()); | ||
|
|
||
| metricsManager.recordLatency(resp.destination(), resp.requestLatencyMs()); |
There was a problem hiding this comment.
moving it to finally will record the metric even if above lines 155 or 156 fail (while getting response and handler), and we don't want that right., same as above
| metrics = new Metrics(metricConfig, time); | ||
| shareFetchMetricsRegistry = new ShareFetchMetricsRegistry(metricConfig.tags().keySet(), "consumer-share" + groupId); | ||
| metricsManager = new ShareFetchMetricsManager(metrics, shareFetchMetricsRegistry); | ||
| metricsManager = spy(new ShareFetchMetricsManager(metrics, shareFetchMetricsRegistry)); |
There was a problem hiding this comment.
Using spy here because the existing tests need the real metric registry to work
c82160e to
50f8e95
Compare
| final FetchResponse response = (FetchResponse) resp.responseBody(); | ||
| final FetchSessionHandler handler = sessionHandler(fetchTarget.id()); | ||
|
|
||
| metricsManager.recordLatency(resp.destination(), resp.requestLatencyMs()); |
There was a problem hiding this comment.
this line should fix the gap for the Async and Classic consumer I expect.
We would just need to add tests to validate it (same as the one added here for the share consumer, but using an error like FETCH_SESSION_TOPIC_ID_ERROR maybe), added to FetcherTest for the classic, and in FetchRequestManagerTest for the async.
There was a problem hiding this comment.
Thanks @lianetm for the review.
Added tests for classic(FetcherTest) and async(FetchRequestManagerTest)
ShivsundarR
left a comment
There was a problem hiding this comment.
Thanks for the PR @muralibasani , LGTM!
|
@lianetm would you be able to take another look ? thanks. |
|
@chia7712 can you pls take a look? |
|
@muralibasani I will read it, sorry for the delay. |
apoorvmittal10
left a comment
There was a problem hiding this comment.
Thanks for the changes, a question for my understanding.
| metadata.updatePartitionLeadership(partitionsWithUpdatedLeaderInfo, leaderNodes); | ||
| } | ||
|
|
||
| if (acknowledgeRequestState.isProcessed) { |
There was a problem hiding this comment.
@muralibasani For my understanding, if there is only ShareAcknowledge request then will we still record latency? I can see code only in handleShareFetchSuccess now.
8adf4cd to
0c09182
Compare
@apoorvmittal10 thanks for the review. |
Ref : https://issues.apache.org/jira/browse/KAFKA-20585
fetch latency metric is recorded twice. In handleShareFetchSuccess and
handleShareAcknowledgeSuccess.
Reviewers: Shivsundar R shr@confluent.io, Apoorv Mittal apoorvmittal10@gmail.com