sergey-chugunov-1985 commented on a change in pull request #8681:
URL: https://github.com/apache/ignite/pull/8681#discussion_r568434221



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
##########
@@ -1521,21 +1525,129 @@ private void checkOrPrepareFiles() throws 
StorageException {
             }
         }
 
-        File[] allFiles = walWorkDir.listFiles(WAL_SEGMENT_FILE_FILTER);
+        FileDescriptor[] walFiles = 
scan(walWorkDir.listFiles(WAL_SEGMENT_FILE_FILTER));
 
-        if (isArchiverEnabled() && !F.isEmpty(allFiles) && allFiles.length > 
dsCfg.getWalSegments()) {
-            throw new StorageException("Failed to initialize wal (work 
directory contains incorrect " +
-                "number of segments) [cur=" + allFiles.length + ", expected=" 
+ dsCfg.getWalSegments() + ']');
-        }
+        if (F.isEmpty(walFiles))
+            createFile(new File(walWorkDir, fileName(0)));
 
-        // Allocate the first segment synchronously. All other segments will 
be allocated by archiver in background.
-        if (F.isEmpty(allFiles)) {
-            File first = new File(walWorkDir, fileName(0));
+        if (isArchiverEnabled()) {

Review comment:
       this part contains a lot of different logic: moving segments to arch 
dir, renaming last segment, formatting segments etc
   
   I strongly believe all these (isolated, to some extent) pieces of code 
should live in their own methods with descriptive names and corresponding 
javadocs. This should improve readability of our code greatly.




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