You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "José Armando García Sancio (Jira)" <ji...@apache.org> on 2024/12/31 21:51:00 UTC

[jira] [Created] (KAFKA-18385) maybeHandleCommonResponse doesn't seem to handle all cases

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)