groupBy v2: Better error message when resources are exhausted. (#4046)

* groupBy v2: Better error message when resources are exhausted.

Fixes #4043.

* Fix tests.
This commit is contained in:
Gian Merlino 2017-03-14 12:07:49 -07:00 committed by Nishant Bangarwa
parent 3216134f8c
commit e5c0dab12c
4 changed files with 20 additions and 6 deletions

View File

@ -256,4 +256,18 @@ public class GroupByQueryHelper
// Don't include post-aggregators since we don't know what types they are.
return types.build();
}
/**
* Throw a {@link ResourceLimitExceededException}. Only used by groupBy v2 when accumulation resources
* are exceeded, triggered by false return from {@link io.druid.query.groupby.epinephelinae.Grouper#aggregate(Object)}.
*
* @return nothing will ever be returned; this return type is for your convenience, similar to
* Throwables.propagate in Guava.
*/
public static ResourceLimitExceededException throwAccumulationResourceLimitExceededException()
{
throw new ResourceLimitExceededException(
"Not enough resources to execute this query. Try increasing druid.query.groupBy.maxOnDiskStorage, "
+ "druid.query.groupBy.maxMergingDictionarySize, or druid.processing.buffer.sizeBytes.");
}
}

View File

@ -52,10 +52,10 @@ import io.druid.query.QueryContextKeys;
import io.druid.query.QueryInterruptedException;
import io.druid.query.QueryRunner;
import io.druid.query.QueryWatcher;
import io.druid.query.ResourceLimitExceededException;
import io.druid.query.aggregation.AggregatorFactory;
import io.druid.query.groupby.GroupByQuery;
import io.druid.query.groupby.GroupByQueryConfig;
import io.druid.query.groupby.GroupByQueryHelper;
import io.druid.query.groupby.epinephelinae.RowBasedGrouperHelper.RowBasedKey;
import java.io.Closeable;
@ -313,7 +313,7 @@ public class GroupByMergingQueryRunnerV2 implements QueryRunner<Row>
for (Boolean result : results) {
if (!result) {
future.cancel(true);
throw new ResourceLimitExceededException("Grouping resources exhausted");
throw GroupByQueryHelper.throwAccumulationResourceLimitExceededException();
}
}
}

View File

@ -33,12 +33,12 @@ import io.druid.java.util.common.guava.CloseQuietly;
import io.druid.java.util.common.guava.FilteredSequence;
import io.druid.java.util.common.guava.Sequence;
import io.druid.query.Query;
import io.druid.query.ResourceLimitExceededException;
import io.druid.query.aggregation.AggregatorFactory;
import io.druid.query.filter.Filter;
import io.druid.query.filter.ValueMatcher;
import io.druid.query.groupby.GroupByQuery;
import io.druid.query.groupby.GroupByQueryConfig;
import io.druid.query.groupby.GroupByQueryHelper;
import io.druid.query.groupby.RowBasedColumnSelectorFactory;
import io.druid.query.groupby.epinephelinae.RowBasedGrouperHelper.RowBasedKey;
import io.druid.query.groupby.resource.GroupByQueryResource;
@ -168,7 +168,7 @@ public class GroupByRowProcessor
accumulator
);
if (retVal != grouper) {
throw new ResourceLimitExceededException("Grouping resources exhausted");
throw GroupByQueryHelper.throwAccumulationResourceLimitExceededException();
}
return RowBasedGrouperHelper.makeGrouperIterator(

View File

@ -1263,7 +1263,7 @@ public class GroupByQueryRunnerTest
List<Row> expectedResults = null;
if (config.getDefaultStrategy().equals(GroupByStrategySelector.STRATEGY_V2)) {
expectedException.expect(ResourceLimitExceededException.class);
expectedException.expectMessage("Grouping resources exhausted");
expectedException.expectMessage("Not enough resources to execute this query");
} else {
expectedResults = Arrays.asList(
GroupByQueryRunnerTestHelper.createExpectedRow("2011-04-01", "alias", "automotive", "rows", 1L, "idx", 135L),
@ -1336,7 +1336,7 @@ public class GroupByQueryRunnerTest
GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
} else {
expectedException.expect(ResourceLimitExceededException.class);
expectedException.expectMessage("Grouping resources exhausted");
expectedException.expectMessage("Not enough resources to execute this query");
GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
}
}