Chia-Ping Tsai created KAFKA-21560:
--------------------------------------

             Summary: “Unexpected error handling request” is logged for every 
broker heartbeat when the active controller changes
                 Key: KAFKA-21560
                 URL: https://issues.apache.org/jira/browse/KAFKA-21560
             Project: Kafka
          Issue Type: Bug
            Reporter: Chia-Ping Tsai
            Assignee: Chia-Ping Tsai


 
{code:java}
        if (!clusterControl.trackBrokerHeartbeat(request.brokerId(), 
request.brokerEpoch())) {
            // Normally, ControllerWriteOperation would automatically check if 
the controller is
            // active. But since we're doing this outside of the main 
controller thread, we have to
            // do our own check here, and handle the case where we are inactive.
            throw 
ControllerExceptions.newWrongControllerException(latestController());
        }
{code}
 

We throw the exception directly and let the handler catch it and then convert 
it to \{{NOT_CONTROLLER}}. It is right in the RPC layer, but it also produces 
misleading messages in the log file since the handler will log it as 
“unexpected error”. However, it should be a normal case since those heartbeat 
requests will be rejected naturally when the active controller is changing.

We could return a failed future instead to eliminate the misleading log. BTW, 
the following log is a case from the previous leader’s log

 
{code:java}
[2026-11-17 12:35:51,854] ERROR [ControllerApis nodeId=3001] Unexpected error 
handling request RequestHeader(apiKey=BROKER_HEARTBEAT, apiVersion=2, 
clientId=1, clientInstanceId=AAAAAAAAAAAAAAAAAAAAAA, correlationId=25, 
headerVersion=2) -- BrokerHeartbeatRequestData(brokerId=1, brokerEpoch=26, 
currentMetadataOffset=123, wantFence=false, wantShutDown=false, 
offlineLogDirs=[], cordonedLogDirs=[]) with context 
RequestContext(header=RequestHeader(apiKey=BROKER_HEARTBEAT, apiVersion=2, 
clientId=1, clientInstanceId=AAAAAAAAAAAAAAAAAAAAAA, correlationId=25, 
headerVersion=2), connectionId='10.89.0.33:9592-10.89.0.35:37146-0-1', 
clientAddress=/10.89.0.35, principal=User:ANONYMOUS, 
listenerName=ListenerName(CONTROLLER_PLAINTEXT), securityProtocol=PLAINTEXT, 
clientInformation=ClientInformation(softwareName=apache-kafka-java, 
softwareVersion=4.5.0-SNAPSHOT), fromPrivilegedListener=false, 
principalSerde=Optional[org.apache.kafka.common.security.authenticator.DefaultKafkaPrincipalBuilder@2c307b67])
 (kafka.server.ControllerApis)
org.apache.kafka.common.errors.NotControllerException: The active controller 
appears to be node 3001.
{code}
 

 



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to