From 018341e82421284627ccb347de7d56e9d534ac27 Mon Sep 17 00:00:00 2001 From: "liming.1018" Date: Fri, 16 Aug 2024 09:47:39 +0800 Subject: [PATCH] [core] fix the issue that BinaryExternalMerger spill files may be leaked. (#3975) --- .../sort/AbstractBinaryExternalMerger.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/sort/AbstractBinaryExternalMerger.java b/paimon-core/src/main/java/org/apache/paimon/sort/AbstractBinaryExternalMerger.java index e1db28c16e23..417ec7a20741 100644 --- a/paimon-core/src/main/java/org/apache/paimon/sort/AbstractBinaryExternalMerger.java +++ b/paimon-core/src/main/java/org/apache/paimon/sort/AbstractBinaryExternalMerger.java @@ -173,7 +173,6 @@ private ChannelWithMeta mergeChannels(List channelIDs) throws I channelManager.addChannel(mergedChannelID); ChannelWriterOutputView output = null; - int numBytesInLastBlock; int numBlocksWritten; try { output = @@ -191,14 +190,14 @@ private ChannelWithMeta mergeChannels(List channelIDs) throws I output.getChannel().deleteChannel(); } throw e; - } - - // remove, close and delete channels - for (FileIOChannel channel : openChannels) { - channelManager.removeChannel(channel.getChannelID()); - try { - channel.closeAndDelete(); - } catch (Throwable ignored) { + } finally { + // remove, close and delete channels + for (FileIOChannel channel : openChannels) { + channelManager.removeChannel(channel.getChannelID()); + try { + channel.closeAndDelete(); + } catch (Throwable ignored) { + } } }