Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-8400

Do not update follower replica state if the log read failed

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.4.0
    • None
    • None

    Description

      In ReplicaManager.fetchMessages, we have the following logic to read from the log and update follower state:

          val result = readFromLocalLog(
              replicaId = replicaId,
              fetchOnlyFromLeader = fetchOnlyFromLeader,
              fetchIsolation = fetchIsolation,
              fetchMaxBytes = fetchMaxBytes,
              hardMaxBytesLimit = hardMaxBytesLimit,
              readPartitionInfo = fetchInfos,
              quota = quota)
            if (isFromFollower) updateFollowerLogReadResults(replicaId, result)
            else result
      

      The call to readFromLocalLog could fail for many reasons, in which case we return a LogReadResult with an error set and all fields set to -1. The problem is that we do not check for the error when updating the follower state. As far as I can tell, this does not cause any correctness issues, but we're just asking for trouble. It would be better to check the error before proceeding to `Partition.updateReplicaLogReadResult`.

      Perhaps even better would be to have readFromLocalLog return something like Either[LogReadResult, Errors] so that we are forced to handle the error.

      Attachments

        Issue Links

          Activity

            People

              hachikuji Jason Gustafson
              hachikuji Jason Gustafson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: