You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by am...@apache.org on 2019/06/24 00:58:49 UTC
[drill] 02/03: DRILL-7297: Query hangs in planning stage when Error
is thrown
This is an automated email from the ASF dual-hosted git repository.
amansinha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
commit d1086772ee4d9f027d3fd6f4673aae43158d2172
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Thu Jun 20 15:33:00 2019 +0300
DRILL-7297: Query hangs in planning stage when Error is thrown
close apache/drill#1811
---
.../apache/drill/exec/work/foreman/Foreman.java | 8 ++---
.../java/org/apache/drill/TestFunctionsQuery.java | 8 +++++
.../exec/fn/impl/testing/CustomErrorFunction.java | 42 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
index ce03303..804254b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
@@ -285,9 +285,9 @@ public class Foreman implements Runnable {
throw new IllegalStateException();
}
injector.injectChecked(queryContext.getExecutionControls(), "run-try-end", ForemanException.class);
- } catch (final ForemanException e) {
+ } catch (ForemanException | UserException e) {
queryStateProcessor.moveToState(QueryState.FAILED, e);
- } catch (final OutOfMemoryError | OutOfMemoryException e) {
+ } catch (OutOfMemoryError | OutOfMemoryException e) {
if (FailureUtils.isDirectMemoryOOM(e)) {
queryStateProcessor.moveToState(QueryState.FAILED, UserException.memoryError(e).build(logger));
} else {
@@ -298,9 +298,7 @@ public class Foreman implements Runnable {
*/
FailureUtils.unrecoverableFailure(e, "Unable to handle out of memory condition in Foreman.", EXIT_CODE_HEAP_OOM);
}
- } catch (UserException e) {
- queryStateProcessor.moveToState(QueryState.FAILED, e);
- } catch (AssertionError | Exception ex) {
+ } catch (Throwable ex) {
queryStateProcessor.moveToState(QueryState.FAILED,
new ForemanException("Unexpected exception during fragment initialization: " + ex.getMessage(), ex));
} finally {
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java
index 16d9789..ae08d92 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java
@@ -18,6 +18,7 @@
package org.apache.drill;
import static org.apache.drill.exec.expr.fn.impl.DateUtility.formatTimeStamp;
+import static org.hamcrest.CoreMatchers.containsString;
import java.math.BigDecimal;
import java.time.Instant;
@@ -1008,4 +1009,11 @@ public class TestFunctionsQuery extends BaseTestQuery {
.go();
}
}
+
+ @Test // DRILL-7297
+ public void testErrorInUdf() throws Exception {
+ expectedException.expect(UserRemoteException.class);
+ expectedException.expectMessage(containsString("Error from UDF"));
+ test("select error_function()");
+ }
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/CustomErrorFunction.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/CustomErrorFunction.java
new file mode 100644
index 0000000..c372e7b
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/CustomErrorFunction.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.fn.impl.testing;
+
+import org.apache.drill.exec.expr.DrillSimpleFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.holders.VarCharHolder;
+
+@FunctionTemplate(
+ name="error_function",
+ scope = FunctionTemplate.FunctionScope.SIMPLE,
+ nulls = FunctionTemplate.NullHandling.NULL_IF_NULL
+)
+public class CustomErrorFunction implements DrillSimpleFunc {
+
+ @Output
+ VarCharHolder output;
+
+ public void setup() {
+ }
+
+ public void eval() {
+ throw new Error("Error from UDF");
+ }
+}
+