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



##########
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:
       > When we load the segments during broker restart, we call 
resizeIndexes() on the last segment. This should trigger the creation of the 
offset index file, which will be flushed on broker shutdown.
   
   The sanityCheck is called before resizeIndexes.
   
   It appears you are talking about we start the broker then immediately shut 
it down. In between the active segment may have been changed, and if the new 
one is empty, no index file is created.




-- 
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-unsubscr...@kafka.apache.org

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


Reply via email to