Github user vvysotskyi commented on a diff in the pull request:
https://github.com/apache/drill/pull/1066#discussion_r161796052
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
---
@@ -1303,6 +1305,8 @@ private void checkGroupAndAggrValues(int
incomingRowIdx) {
long memDiff = allocator.getAllocatedMemory() - allocatedBeforeHTput;
if ( memDiff > 0 ) { logger.warn("Leak: HashTable put() OOM left
behind {} bytes allocated",memDiff); }
+ checkForSpillPossibility(currentPartition);
--- End diff --
These checks were needed to avoid infinite loop when there is not enough
memory for the spill.
I moved these checks into `spillIfNeeded()` method, so when called
`doSpill()`, `forceSpill` in `spillIfNeeded()` is true and check should be done.
---