sashapolo commented on code in PR #7880:
URL: https://github.com/apache/ignite-3/pull/7880#discussion_r3020357801


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/RaftLogGarbageCollector.java:
##########
@@ -137,29 +207,43 @@ void cleanupLeftoverFiles() throws IOException {
     }
 
     @VisibleForTesting
-    void runCompaction(SegmentFile segmentFile) throws IOException {
-        LOG.info("Compacting segment file [path = {}].", segmentFile.path());
+    long logSizeBytes() {
+        return logSizeBytes.get();
+    }
+
+    @VisibleForTesting
+    void runCompaction(FileProperties segmentFileProperties) throws 
IOException {
+        Path segmentFilePath = 
segmentFilesDir.resolve(SegmentFile.fileName(segmentFileProperties));
+
+        LOG.info("Compacting segment file [path = {}].", segmentFilePath);
 
+        // TODO: Skip non-compactible files, see 
https://issues.apache.org/jira/browse/IGNITE-28417.
         Long2ObjectMap<IndexFileMeta> segmentFileDescription
-                = 
indexFileManager.describeSegmentFile(segmentFile.fileProperties().ordinal());
+                = 
indexFileManager.describeSegmentFile(segmentFileProperties.ordinal());
 
         boolean canRemoveSegmentFile = segmentFileDescription.isEmpty();
 
-        Path indexFilePath = 
indexFileManager.indexFilePath(segmentFile.fileProperties());
+        Path indexFilePath = 
indexFileManager.indexFilePath(segmentFileProperties);
 
         long logSizeDelta;
 
         if (canRemoveSegmentFile) {
-            indexFileManager.onIndexFileRemoved(segmentFile.fileProperties());
+            indexFileManager.onIndexFileRemoved(segmentFileProperties);
 
-            logSizeDelta = Files.size(segmentFile.path()) + 
Files.size(indexFilePath);
+            logSizeDelta = Files.size(segmentFilePath) + 
Files.size(indexFilePath);
         } else {
-            logSizeDelta = compactSegmentFile(segmentFile, indexFilePath, 
segmentFileDescription);
+            SegmentFile segmentFile = 
SegmentFile.openExisting(segmentFilePath, false);
+
+            try {
+                logSizeDelta = compactSegmentFile(segmentFile, indexFilePath, 
segmentFileDescription);
+            } finally {
+                segmentFile.close();
+            }
         }
 
         // Remove the previous generation of the segment file and its index. 
This is safe to do, because we rely on the file system
         // guarantees that other threads reading from the segment file will 
still be able to do that even if the file is deleted.
-        Files.delete(segmentFile.path());
+        Files.delete(segmentFilePath);

Review Comment:
   > Does that mean that this operation can fail with an exception?
   
   yes, and this is a bug in this case, I'll try to test it on a Windows 
machine (though not with a high priority)



-- 
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: [email protected]

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

Reply via email to