You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/11/18 00:14:05 UTC

[GitHub] [pinot] klsince commented on a diff in pull request #9797: fix potential fd leakage for SegmentProcessorFramework

klsince commented on code in PR #9797:
URL: https://github.com/apache/pinot/pull/9797#discussion_r1025862341


##########
pinot-core/src/main/java/org/apache/pinot/core/segment/processing/framework/SegmentProcessorFramework.java:
##########
@@ -142,28 +142,31 @@ public List<File> process()
     for (Map.Entry<String, GenericRowFileManager> entry : partitionToFileManagerMap.entrySet()) {
       String partitionId = entry.getKey();
       GenericRowFileManager fileManager = entry.getValue();
-      GenericRowFileReader fileReader = fileManager.getFileReader();
-      int numRows = fileReader.getNumRows();
-      int numSortFields = fileReader.getNumSortFields();
-      LOGGER.info("Start creating segments on partition: {}, numRows: {}, numSortFields: {}", partitionId, numRows,
-          numSortFields);
-      GenericRowFileRecordReader recordReader = fileReader.getRecordReader();
-      for (int startRowId = 0; startRowId < numRows; startRowId += maxNumRecordsPerSegment, sequenceId++) {
-        int endRowId = Math.min(startRowId + maxNumRecordsPerSegment, numRows);
-        LOGGER.info("Start creating segment of sequenceId: {} with row range: {} to {}", sequenceId, startRowId,
-            endRowId);
-        observer.accept(String.format(
-            "Creating segment of sequentId: %d with data from partition: %s and row range: [%d, %d) out of [0, %d)",
-            sequenceId, partitionId, startRowId, endRowId, numRows));
-        generatorConfig.setSequenceId(sequenceId);
-        GenericRowFileRecordReader recordReaderForRange = recordReader.getRecordReaderForRange(startRowId, endRowId);
-        SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl();
-        driver.init(generatorConfig, new RecordReaderSegmentCreationDataSource(recordReaderForRange),
-            TransformPipeline.getPassThroughPipeline());
-        driver.build();
-        outputSegmentDirs.add(driver.getOutputDirectory());
+      try {
+        GenericRowFileReader fileReader = fileManager.getFileReader();
+        int numRows = fileReader.getNumRows();
+        int numSortFields = fileReader.getNumSortFields();
+        LOGGER.info("Start creating segments on partition: {}, numRows: {}, numSortFields: {}", partitionId, numRows,
+            numSortFields);
+        GenericRowFileRecordReader recordReader = fileReader.getRecordReader();
+        for (int startRowId = 0; startRowId < numRows; startRowId += maxNumRecordsPerSegment, sequenceId++) {
+          int endRowId = Math.min(startRowId + maxNumRecordsPerSegment, numRows);
+          LOGGER.info("Start creating segment of sequenceId: {} with row range: {} to {}", sequenceId, startRowId,
+              endRowId);
+          observer.accept(String.format(
+              "Creating segment of sequentId: %d with data from partition: %s and row range: [%d, %d) out of [0, %d)",
+              sequenceId, partitionId, startRowId, endRowId, numRows));
+          generatorConfig.setSequenceId(sequenceId);
+          GenericRowFileRecordReader recordReaderForRange = recordReader.getRecordReaderForRange(startRowId, endRowId);
+          SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl();
+          driver.init(generatorConfig, new RecordReaderSegmentCreationDataSource(recordReaderForRange),
+              TransformPipeline.getPassThroughPipeline());
+          driver.build();
+          outputSegmentDirs.add(driver.getOutputDirectory());
+        }
+      } finally {
+        fileManager.cleanUp();

Review Comment:
   _mapperOutputDir and _reducerOutputDir are internal to this framework, so the caller can't check their existence. And when the issue happened, the files were deleted (file names were gone from the file system). But as it's still opened by the process via mmap, so the file (inode, disk space) was not released cleanly. 



-- 
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: commits-unsubscribe@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org