José Armando García Sancio created KAFKA-18385:
--------------------------------------------------

             Summary: maybeHandleCommonResponse doesn't seem to handle all cases
                 Key: KAFKA-18385
                 URL: https://issues.apache.org/jira/browse/KAFKA-18385
             Project: Kafka
          Issue Type: Sub-task
          Components: kraft
            Reporter: José Armando García Sancio
            Assignee: José Armando García Sancio


It is possible for a replica to know the leader id but not the leader's 
endpoint. This can happen when the replica restart and the voter set that 
includes the leader has not bee replicated in the log.

In this case the replica will start as unattached with a leader id. In 
unattached it will send FETCH request to the bootstrap servers until a 
bootstrap server provides the leader id and leader's endpoint in the FETCH 
response.

This response is supposed to be handled by maybeHandleCommonResponse but this 
logic doesn't seem correct:
{code:java}
          } else if (epoch == quorum.epoch()
              && leaderId.isPresent()
              && !quorum.hasLeader()) {              // Since we are 
transitioning to Follower, we will only forward the
              // request to the handler if there is no error. Otherwise, we 
will let
              // the request be retried immediately (if needed) after the 
transition.
              // This handling allows an observer to discover the leader and 
append
              // to the log in the same Fetch request.
              transitionToFollower(epoch, leaderId.getAsInt(), leaderEndpoints, 
currentTimeMs);
              if (error == Errors.NONE) {
                  return Optional.empty();
              } else {
                  return Optional.of(value: true);
              }
 } {code}
One possible fix is to check if the locally known leader endpoints is empty in 
the predicate for the if expression.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to