This is an automated email from the ASF dual-hosted git repository.
cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 86d3c665fb DRILL-8483: SpilledRecordBatch memory leak when the program
threw an exception during the process of building a hash table (#2887) (#2888)
86d3c665fb is described below
commit 86d3c665fb79fe782393e580f09d82010019ac14
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 42dbc1cbfc..3fef85f20a 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();
+ }
}
}