You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by om...@apache.org on 2025/10/09 14:28:14 UTC

(kafka) branch trunk updated: KAFKA-19776: Fix log values for previous leader id and epoch (#20671)

This is an automated email from the ASF dual-hosted git repository.

omnia pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new cedf1c052e9 KAFKA-19776: Fix log values for previous leader id and epoch (#20671)
cedf1c052e9 is described below

commit cedf1c052e903967982891e05d95f4a6cd4c4faf
Author: Gaurav Narula <ga...@apple.com>
AuthorDate: Thu Oct 9 15:28:07 2025 +0100

    KAFKA-19776: Fix log values for previous leader id and epoch (#20671)
    
    Stores the existing values for both the fields in a local variable for
    logging.
    
    Reviewers: Omnia Ibrahim <o....@gmail.com>
---
 core/src/main/scala/kafka/cluster/Partition.scala | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/cluster/Partition.scala b/core/src/main/scala/kafka/cluster/Partition.scala
index f47160a9119..53228873e5d 100755
--- a/core/src/main/scala/kafka/cluster/Partition.scala
+++ b/core/src/main/scala/kafka/cluster/Partition.scala
@@ -855,6 +855,8 @@ class Partition(val topicPartition: TopicPartition,
       val isNewLeaderEpoch = partitionRegistration.leaderEpoch > leaderEpoch
       // The leader should be updated before updateAssignmentAndIsr where we clear the ISR. Or it is possible to meet
       // the under min isr condition during the makeFollower process and emits the wrong metric.
+      val prevLeaderReplicaIdOpt = leaderReplicaIdOpt
+      val prevLeaderEpoch = leaderEpoch
       leaderReplicaIdOpt = Option(partitionRegistration.leader)
       leaderEpoch = partitionRegistration.leaderEpoch
       leaderEpochStartOffsetOpt = None
@@ -877,7 +879,7 @@ class Partition(val topicPartition: TopicPartition,
         stateChangeLogger.info(s"Follower $topicPartition starts at leader epoch ${partitionRegistration.leaderEpoch} from " +
           s"offset $leaderEpochEndOffset with partition epoch ${partitionRegistration.partitionEpoch} and " +
           s"high watermark ${followerLog.highWatermark}. Current leader is ${partitionRegistration.leader}. " +
-          s"Previous leader $leaderReplicaIdOpt and previous leader epoch was $leaderEpoch.")
+          s"Previous leader $prevLeaderReplicaIdOpt and previous leader epoch was $prevLeaderEpoch.")
       } else {
         stateChangeLogger.info(s"Skipped the become-follower state change for $topicPartition with topic id $topicId, " +
           s"partition registration $partitionRegistration and isNew=$isNew since it is already a follower with leader epoch $leaderEpoch.")