apoorvmittal10 commented on code in PR #19637: URL: https://github.com/apache/kafka/pull/19637#discussion_r2075641438
########## core/src/test/scala/unit/kafka/server/KafkaApisTest.scala: ########## @@ -6380,6 +6380,42 @@ class KafkaApisTest extends Logging { assertEquals(0, topicResponses.get(0).partitions.get(0).acquiredRecords.toArray().length) } + @Test + def handleShareFetchRequestThrottlingWhenSessionCacheIsFull(): Unit = { + metadataCache = initializeMetadataCacheWithShareGroupsEnabled() + + val groupId = "group" + val memberId: Uuid = Uuid.ZERO_UUID + val maxWaitMs: Int = 2000 + + doThrow(new ShareSessionLimitReachedException("Share session exceeded")) + .when(sharePartitionManager).newContext(any(), any(), any(), any(), any(), any()); + + val shareFetchRequestData = new ShareFetchRequestData(). + setGroupId(groupId). + setMemberId(memberId.toString). + setShareSessionEpoch(ShareRequestMetadata.INITIAL_EPOCH). + setTopics(List().asJava). + setMaxWaitMs(maxWaitMs) + + val shareFetchRequest = new ShareFetchRequest.Builder(shareFetchRequestData).build(ApiKeys.SHARE_FETCH.latestVersion) + val request = buildRequest(shareFetchRequest) + kafkaApis = createKafkaApis() + kafkaApis.handleShareFetchRequest(request) + val response = verifyNoThrottling[ShareFetchResponse](request) + val responseData = response.data() + + val expectedThrottleTimeMs = maxWaitMs + + verify(clientRequestQuotaManager).throttle( + ArgumentMatchers.eq(request), + any[ThrottleCallback](), + ArgumentMatchers.eq(expectedThrottleTimeMs) + ) + + assertEquals(expectedThrottleTimeMs, responseData.throttleTimeMs) + } Review Comment: Can we extend this case where a subsequent `handleShareFetchRequest` should return throttled response. Also please add an e2e test case in `ShareFetchAcknowledgeRequestTest`. ########## core/src/main/scala/kafka/server/KafkaApis.scala: ########## @@ -3049,6 +3049,11 @@ class KafkaApis(val requestChannel: RequestChannel, // Creating the shareFetchContext for Share Session Handling. if context creation fails, the request is failed directly here. shareFetchContext = sharePartitionManager.newContext(groupId, shareFetchData, forgottenTopics, newReqMetadata, isAcknowledgeDataPresent, request.context.connectionId) } catch { + case e: ShareSessionLimitReachedException => + // Throttle for maxWaitMs when share session limit is reached + requestHelper.throttle(quotas.request, request, shareFetchRequest.maxWait) Review Comment: Does this mean that client will not be able to make any request for the maxWait time? Does that mean `metadata` and `heartbeat` calls will also be muted for the client? -- 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