showuon commented on a change in pull request #10794: URL: https://github.com/apache/kafka/pull/10794#discussion_r654763984
########## File path: core/src/main/scala/kafka/network/RequestChannel.scala ########## @@ -124,8 +124,15 @@ object RequestChannel extends Logging { def buildResponseSend(abstractResponse: AbstractResponse): Send = { envelope match { case Some(request) => - val responseBytes = context.buildResponseEnvelopePayload(abstractResponse) - val envelopeResponse = new EnvelopeResponse(responseBytes, Errors.NONE) + val envelopeResponse = if (abstractResponse.errorCounts().containsKey(Errors.NOT_CONTROLLER)) { + // Since it's Not Controller error response, we need to make envelope response with Not Controller error + // to notify the requester (i.e. BrokerToControllerRequestThread) to update active controller + new EnvelopeResponse(new EnvelopeResponseData() + .setErrorCode(Errors.NOT_CONTROLLER.code())) Review comment: fix 2: Make the envelope response return `NotControllerException` if the controller response has `NotControllerException`. So that we can catch the `NotControllerException` on envelopeResponse to update the active controller. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org