Skip to content

Commit 95a6c93

Browse files
DRILL-8484: HashJoinPOP Memory Leak is Caused by an OOM Exception when read data from Stream with container (#2889)
1 parent 3e96562 commit 95a6c93

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

exec/java-exec/src/main/java/org/apache/drill/exec/cache/VectorAccessibleSerializable.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626

2727
import org.apache.drill.common.exceptions.UserException;
28+
import org.apache.drill.exec.exception.OutOfMemoryException;
2829
import org.apache.drill.exec.expr.TypeHelper;
2930
import org.apache.drill.exec.memory.BufferAllocator;
3031
import org.apache.drill.exec.metrics.DrillMetrics;
@@ -164,14 +165,22 @@ public void readFromStreamWithContainer(VectorContainer myContainer, InputStream
164165
for (SerializedField metaData : fieldList) {
165166
final int dataLength = metaData.getBufferLength();
166167
final MaterializedField field = MaterializedField.create(metaData);
167-
final DrillBuf buf = allocator.buffer(dataLength);
168-
final ValueVector vector;
168+
DrillBuf buf = null;
169+
ValueVector vector = null;
169170
try {
171+
buf = allocator.buffer(dataLength);
170172
buf.writeBytes(input, dataLength);
171173
vector = TypeHelper.getNewVector(field, allocator);
172174
vector.load(metaData, buf);
175+
} catch (OutOfMemoryException oom) {
176+
for (ValueVector valueVector : vectorList) {
177+
valueVector.clear();
178+
}
179+
throw UserException.memoryError(oom).message("Allocator memory failed").build(logger);
173180
} finally {
174-
buf.release();
181+
if (buf != null) {
182+
buf.release();
183+
}
175184
}
176185
vectorList.add(vector);
177186
}

0 commit comments

Comments
 (0)