You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jg...@apache.org on 2018/03/18 18:21:53 UTC

[kafka] branch trunk updated: MINOR: Use log start offset as high watermark if current value is out of range (#4722)

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

jgus 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 4391a42  MINOR: Use log start offset as high watermark if current value is out of range (#4722)
4391a42 is described below

commit 4391a4214de7594e64de4b0b0d5a1196813b04b8
Author: Dong Lin <li...@users.noreply.github.com>
AuthorDate: Sun Mar 18 11:21:44 2018 -0700

    MINOR: Use log start offset as high watermark if current value is out of range (#4722)
    
    Reviewers: Jun Rao <ju...@gmail.com>, Jason Gustafson <ja...@confluent.io>
---
 core/src/main/scala/kafka/cluster/Replica.scala | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/src/main/scala/kafka/cluster/Replica.scala b/core/src/main/scala/kafka/cluster/Replica.scala
index 030e5b7..4b65e43 100644
--- a/core/src/main/scala/kafka/cluster/Replica.scala
+++ b/core/src/main/scala/kafka/cluster/Replica.scala
@@ -175,8 +175,10 @@ class Replica(val brokerId: Int,
   def convertHWToLocalOffsetMetadata() {
     if (isLocal) {
       highWatermarkMetadata = log.get.convertToOffsetMetadata(highWatermarkMetadata.messageOffset).getOrElse {
-        val firstOffset = log.get.logSegments.head.baseOffset
-        new LogOffsetMetadata(firstOffset, firstOffset, 0)
+        log.get.convertToOffsetMetadata(logStartOffset).getOrElse {
+          val firstSegmentOffset = log.get.logSegments.head.baseOffset
+          new LogOffsetMetadata(firstSegmentOffset, firstSegmentOffset, 0)
+        }
       }
     } else {
       throw new KafkaException(s"Should not construct complete high watermark on partition $topicPartition's non-local replica $brokerId")

-- 
To stop receiving notification emails like this one, please contact
jgus@apache.org.