junrao commented on a change in pull request #10405:
URL: https://github.com/apache/kafka/pull/10405#discussion_r605955876



##########
File path: core/src/main/scala/kafka/log/Log.scala
##########
@@ -320,7 +320,7 @@ class Log(@volatile private var _dir: File,
     initializeLeaderEpochCache()
     initializePartitionMetadata()
 
-    val nextOffset = loadSegments()
+    val nextOffset = loadSegments(hadCleanShutdown)

Review comment:
       There is no need to pass hadCleanShutdown in since it's already 
accessible from loadSegments().

##########
File path: clients/src/main/java/org/apache/kafka/common/record/FileRecords.java
##########
@@ -424,21 +439,22 @@ public static FileRecords open(File file,
                                    boolean mutable,
                                    boolean fileAlreadyExists,
                                    int initFileSize,
-                                   boolean preallocate) throws IOException {
+                                   boolean preallocate,
+                                   boolean hadCleanShutdown) throws 
IOException {
         FileChannel channel = openChannel(file, mutable, fileAlreadyExists, 
initFileSize, preallocate);
         int end = (!fileAlreadyExists && preallocate) ? 0 : Integer.MAX_VALUE;
-        return new FileRecords(file, channel, 0, end, false);
+        return new FileRecords(file, channel, 0, end, false, mutable && 
!hadCleanShutdown);
     }
 
     public static FileRecords open(File file,
                                    boolean fileAlreadyExists,
                                    int initFileSize,
-                                   boolean preallocate) throws IOException {
-        return open(file, true, fileAlreadyExists, initFileSize, preallocate);
+                                   boolean preallocate, boolean 
hadCleanShutdown) throws IOException {

Review comment:
       It's probably more intuitive to change hadCleanShutdown to needsRecovery 
and pass in the negation of the flag. Then, the default value of false makes 
more sense.
   
   Also, could we put the change in a separate line to match the existing 
format?




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to