This is an automated email from the ASF dual-hosted git repository. dzamo pushed a commit to branch 1.21 in repository https://gitbox.apache.org/repos/asf/drill.git
commit 034a698afd3c835dc26710f1441a30850eae67b1 Author: shfshihuafeng <[email protected]> AuthorDate: Sat Mar 30 05:32:45 2024 +0800 DRILL-8483: SpilledRecordBatch memory leak when the program threw an exception during the process of building a hash table (#2887) (#2888) --- .../impl/join/AbstractHashBinaryRecordBatch.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java index 9785b9d177..bef097c2b5 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/AbstractHashBinaryRecordBatch.java @@ -532,6 +532,8 @@ public abstract class AbstractHashBinaryRecordBatch<T extends PhysicalOperator> return rightUpstream; } + boolean isExistException = false; + try { /* * If we are here for the first time, execute the build phase of the hash @@ -687,6 +689,24 @@ public abstract class AbstractHashBinaryRecordBatch<T extends PhysicalOperator> return IterOutcome.NONE; } catch (SchemaChangeException e) { throw UserException.schemaChangeError(e).build(logger); + } catch (OutOfMemoryException oom) { + isExistException = true; + throw UserException.memoryError(oom).build(logger); + } catch (Exception e) { + //Internal catch OutOfMemoryException, resulting in throwing other exceptions or others + isExistException = true; + throw UserException.executionError(e).build(logger); + } finally { + boolean isReleaseBuildBatch = buildBatch != null && buildBatch instanceof SpilledRecordBatch; + boolean isReleaseProbeBatch = probeBatch != null && probeBatch instanceof SpilledRecordBatch; + //release buildBatch spill memory + if (isExistException && isReleaseBuildBatch) { + buildBatch.cancel(); + } + //release probeBatch spill memory + if (isExistException && isReleaseProbeBatch) { + probeBatch.cancel(); + } } }
