Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-9876 Implement Raft Protocol for Metadata Quorum
  3. KAFKA-12331

KafkaRaftClient should use the LEO when appending LeaderChangeMessage

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • replication
    • None

    Description

      KafkaMetadataLog's appendAsLeader expects the base offset to match the LEO. This is enforced when KafkaRaftClient uses the BatchAccumulator to create batches. When creating the control batch for the LeaderChangeMessage the KafkaRaftClient doesn't use the BatchAccumulator and instead creates the batch with the default base offset of 0.

      This causes the validation in KafkaMetadataLog to fail with the following exception:

      kafka.common.UnexpectedAppendOffsetException: Unexpected offset in append to @metadata-0. First offset 0 is less than the next offset 5. First 10 offsets in append: ArrayBuffer(0), last offset in append: 0. Log start offset = 0
      	at kafka.log.Log.append(Log.scala:1217)
      	at kafka.log.Log.appendAsLeader(Log.scala:1092)
      	at kafka.raft.KafkaMetadataLog.appendAsLeader(KafkaMetadataLog.scala:92)
      	at org.apache.kafka.raft.KafkaRaftClient.appendAsLeader(KafkaRaftClient.java:1158)
      	at org.apache.kafka.raft.KafkaRaftClient.appendLeaderChangeMessage(KafkaRaftClient.java:449)
      	at org.apache.kafka.raft.KafkaRaftClient.onBecomeLeader(KafkaRaftClient.java:409)
      	at org.apache.kafka.raft.KafkaRaftClient.maybeTransitionToLeader(KafkaRaftClient.java:463)
      	at org.apache.kafka.raft.KafkaRaftClient.handleVoteResponse(KafkaRaftClient.java:663)
      	at org.apache.kafka.raft.KafkaRaftClient.handleResponse(KafkaRaftClient.java:1530)
      	at org.apache.kafka.raft.KafkaRaftClient.handleInboundMessage(KafkaRaftClient.java:1652)
      	at org.apache.kafka.raft.KafkaRaftClient.poll(KafkaRaftClient.java:2183)
      	at kafka.raft.KafkaRaftManager$RaftIoThread.doWork(RaftManager.scala:52)
      	at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96) 

      We should make the following changes:

      1. Fix MockLog to perform similar validation as KafkaMetadataLog::appendAsLeader
      2. Use the LEO when creating the control batch for the LeaderChangedMessage

      Attachments

        Issue Links

          Activity

            People

              jagsancio Jose Armando Garcia Sancio
              jsancio José Armando García Sancio
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: