mayankshriv commented on a change in pull request #5768: URL: https://github.com/apache/incubator-pinot/pull/5768#discussion_r463124006
########## File path: pinot-server/src/main/java/org/apache/pinot/server/starter/helix/SegmentFetcherAndLoader.java ########## @@ -202,18 +206,22 @@ private String downloadSegmentToLocal(String uri, PinotCrypter crypter, String t .info("Downloaded tarred segment: {} for table: {} from: {} to: {}, file length: {}", segmentName, tableName, uri, tempTarFile, tempTarFile.length()); - // If an exception is thrown when untarring, it means the tar file is broken OR not found after the retry. - // Thus, there's no need to retry again. - File tempIndexDir = TarGzCompressionUtils.untar(tempTarFile, tempSegmentDir).get(0); - - File indexDir = new File(new File(_instanceDataManager.getSegmentDataDirectory(), tableName), segmentName); - if (indexDir.exists()) { - LOGGER.info("Deleting existing index directory for segment: {} for table: {}", segmentName, tableName); - FileUtils.deleteDirectory(indexDir); + try { + // If an exception is thrown when untarring, it means the tar file is broken OR not found after the retry. + // Thus, there's no need to retry again. + File tempIndexDir = TarGzCompressionUtils.untar(tempTarFile, tempSegmentDir).get(0); + File indexDir = new File(new File(_instanceDataManager.getSegmentDataDirectory(), tableName), segmentName); + if (indexDir.exists()) { + LOGGER.info("Deleting existing index directory for segment: {} for table: {}", segmentName, tableName); + FileUtils.deleteDirectory(indexDir); + } + FileUtils.moveDirectory(tempIndexDir, indexDir); + LOGGER.info("Successfully downloaded segment: {} for table: {} to: {}", segmentName, tableName, indexDir); + return indexDir.getAbsolutePath(); + } catch (Exception e) { + _serverMetrics.addMeteredTableValue(tableName, ServerMeter.UNTAR_FAILURES, 1L); + throw e; Review comment: Utils.rethrow() will keep the original exception type. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org