Skip to content

Commit

Permalink
DRILL-8484: HashJoinPOP Memory Leak is Caused by an OOM Exception whe…
Browse files Browse the repository at this point in the history
…n read data from Stream with container (#2889)
  • Loading branch information
shfshihuafeng authored Mar 29, 2024
1 parent 3e96562 commit 95a6c93
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;

import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.exception.OutOfMemoryException;
import org.apache.drill.exec.expr.TypeHelper;
import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.metrics.DrillMetrics;
Expand Down Expand Up @@ -164,14 +165,22 @@ public void readFromStreamWithContainer(VectorContainer myContainer, InputStream
for (SerializedField metaData : fieldList) {
final int dataLength = metaData.getBufferLength();
final MaterializedField field = MaterializedField.create(metaData);
final DrillBuf buf = allocator.buffer(dataLength);
final ValueVector vector;
DrillBuf buf = null;
ValueVector vector = null;
try {
buf = allocator.buffer(dataLength);
buf.writeBytes(input, dataLength);
vector = TypeHelper.getNewVector(field, allocator);
vector.load(metaData, buf);
} catch (OutOfMemoryException oom) {
for (ValueVector valueVector : vectorList) {
valueVector.clear();
}
throw UserException.memoryError(oom).message("Allocator memory failed").build(logger);
} finally {
buf.release();
if (buf != null) {
buf.release();
}
}
vectorList.add(vector);
}
Expand Down

0 comments on commit 95a6c93

Please sign in to comment.