You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/10/01 00:31:27 UTC

[GitHub] [kafka] kowshik commented on a change in pull request #11345: Allow empty last segment to have missing offset index during recovery

kowshik commented on a change in pull request #11345:
URL: https://github.com/apache/kafka/pull/11345#discussion_r719860600



##########
File path: core/src/main/scala/kafka/log/LogSegment.scala
##########
@@ -77,8 +77,9 @@ class LogSegment private[log] (val log: FileRecords,
     timeIndex.resize(size)
   }
 
-  def sanityCheck(timeIndexFileNewlyCreated: Boolean): Unit = {
-    if (lazyOffsetIndex.file.exists) {
+  def sanityCheck(timeIndexFileNewlyCreated: Boolean, isActiveSegment: Boolean): Unit = {
+    // We allow for absence of offset index file only for an empty active segment.
+    if ((isActiveSegment && size == 0) || lazyOffsetIndex.file.exists) {

Review comment:
       @junrao Sounds good to me. We can flush the active segment during clean shutdown. That's a very elegant way to handle this problem.
   
   @ccding Would you like to update the PR with the approach proposed by @junrao?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org