From 0b622e4692b8577fc54057584d582f18a261ceb9 Mon Sep 17 00:00:00 2001 From: PLASH SPEED Date: Tue, 26 Nov 2024 10:50:52 +0800 Subject: [PATCH] HIVE-15221:Improvement for MapJoin checkMemoryStatus, adding gc before throwing Exception https://issues.apache.org/jira/browse/HIVE-15221 --- .../ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java index 35a86b167c55..08475743fe99 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/mapjoin/MapJoinMemoryExhaustionHandler.java @@ -96,7 +96,12 @@ public void checkMemoryStatus(long tableContainerSize, long numRows) + tableContainerSize + "\tMemory usage:\t" + usedMemory + "\tpercentage:\t" + percentageNumberFormat.format(percentage); console.printInfo(msg); if(percentage > maxMemoryUsage) { - throw new MapJoinMemoryExhaustionError(msg); + System.gc(); + usedMemory = memoryMXBean.getHeapMemoryUsage().getUsed(); + percentage = (double) usedMemory / (double) maxHeapSize; + if(percentage > maxMemoryUsage) { + throw new MapJoinMemoryExhaustionError(msg); + } } } }