tkalkirill commented on code in PR #1325:
URL: https://github.com/apache/ignite-3/pull/1325#discussion_r1031175327


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStoreManager.java:
##########
@@ -139,31 +149,63 @@ public void start() throws IgniteInternalCheckedException 
{
             throw new IgniteInternalCheckedException("Could not create work 
directory for page stores: " + dbDir, e);
         }
 
-        if (log.isWarnEnabled()) {
+        if (LOG.isWarnEnabled()) {
             String tmpDir = System.getProperty("java.io.tmpdir");
 
             if (tmpDir != null && this.dbDir.startsWith(tmpDir)) {
-                log.warn("Persistence store directory is in the temp directory 
and may be cleaned. "
+                LOG.warn("Persistence store directory is in the temp directory 
and may be cleaned. "
                         + "To avoid this change location of persistence 
directories [currentDir={}]", this.dbDir);
             }
         }
 
+        List<Path> toDelete = new ArrayList<>();
+
         try (Stream<Path> tmpFileStream = Files.find(
                 dbDir,
                 Integer.MAX_VALUE,
-                (path, basicFileAttributes) -> 
path.getFileName().toString().endsWith(TMP_FILE_SUFFIX)
-        )) {
-            List<Path> tmpFiles = tmpFileStream.collect(toList());
+                (path, basicFileAttributes) -> 
path.getFileName().toString().endsWith(TMP_FILE_SUFFIX))
+        ) {
+            toDelete.addAll(tmpFileStream.collect(toList()));
+        } catch (IOException e) {
+            throw new IgniteInternalCheckedException("Error while searching 
temporary files:" + dbDir, e);
+        }
+
+        Pattern delPartitionFilePatter = Pattern.compile(DEL_PART_FILE_REGEXP);
+
+        try (Stream<Path> delFileStream = Files.find(
+                dbDir,
+                Integer.MAX_VALUE,
+                (path, basicFileAttributes) -> 
path.getFileName().toString().endsWith(DEL_FILE_SUFFIX))
+        ) {
+            delFileStream.forEach(delFilePath -> {
+                Matcher matcher = 
delPartitionFilePatter.matcher(delFilePath.getFileName().toString());
 
-            if (!tmpFiles.isEmpty()) {
-                if (log.isInfoEnabled()) {
-                    log.info("Temporary files to be deleted: {}", 
tmpFiles.size());
+                if (!matcher.matches()) {
+                    throw new IgniteInternalException("Unknown file: " + 
delFilePath);
                 }
 
-                tmpFiles.forEach(IgniteUtils::deleteIfExists);
-            }
+                Path tableWorkDir = delFilePath.getParent();
+
+                int partitionId = Integer.parseInt(matcher.group(1));
+
+                
toDelete.add(tableWorkDir.resolve(String.format(PART_FILE_TEMPLATE, 
partitionId)));
+
+                try {
+                    
toDelete.addAll(List.of(findPartitionDeltaFiles(tableWorkDir, partitionId)));
+                } catch (IgniteInternalCheckedException e) {
+                    throw new IgniteInternalException("Error when searching 
delta files for partition:" + delFilePath, e);
+                }
+
+                toDelete.add(delFilePath);
+            });
         } catch (IOException e) {
-            throw new IgniteInternalCheckedException("Could not create work 
directory for page stores: " + dbDir, e);
+            throw new IgniteInternalCheckedException("Error while searching 
temporary files:" + dbDir, e);
+        }
+
+        if (!toDelete.isEmpty()) {
+            LOG.info("Files to be deleted: {}", toDelete);

Review Comment:
   There can be many files and for all tables, I don't think it's worth 
changing the message.



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