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
  • Loading branch information
shfshihuafeng committed Mar 24, 2024
1 parent 26f4d30 commit 1f60467
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.OutputStream;
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 @@ -155,14 +157,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 1f60467

Please sign in to comment.