Skip to content
Permalink
Browse files
DRILL-6591: Show Exception for failed queries submitted in WebUI
* DRILL-6591: Show Exception for failed queries submitted in WebUI

When query fails on Web UI result page no error is shown, only "No result found." 
This was because DRILL-6477 (PR #1309) switched to `WebUserConnection.await(long timeoutInMillis)` . Unlike the original `WebUserConnection.await()`, this method did not throw any UserException generated by a query failure. The fix was to use WebUserConnection.getError() method to know about failure of the query and throw UserRemoteException with that.

closes #1379
  • Loading branch information
kkhatua authored and sohami committed Jul 13, 2018
1 parent feb99ac commit e3534b6a9f1369a355d250a9e915ee40bca17444
Showing 1 changed file with 16 additions and 15 deletions.
@@ -22,6 +22,7 @@
import com.google.common.collect.Maps;

import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.common.exceptions.UserRemoteException;
import org.apache.drill.exec.proto.UserBitShared.QueryId;
import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
import org.apache.drill.exec.proto.UserBitShared.QueryType;
@@ -86,9 +87,8 @@ public QueryResult run(final WorkManager workManager, final WebUserConnection we
logger.debug("Wait until the query execution is complete or there is error submitting the query");
do {
try {
isComplete = webUserConnection.await(TimeUnit.SECONDS.toMillis(1)); /*periodically timeout to check heap*/
} catch (Exception e) { }

isComplete = webUserConnection.await(TimeUnit.SECONDS.toMillis(1)); //periodically timeout 1 sec to check heap
} catch (InterruptedException e) {}
usagePercent = getHeapUsage();
if (usagePercent > HEAP_MEMORY_FAILURE_THRESHOLD) {
nearlyOutOfHeapSpace = true;
@@ -97,21 +97,22 @@ public QueryResult run(final WorkManager workManager, final WebUserConnection we

//Fail if nearly out of heap space
if (nearlyOutOfHeapSpace) {
UserException almostOutOfHeapException = UserException.resourceError()
.message("There is not enough heap memory to run this query using the web interface. ")
.addContext("Please try a query with fewer columns or with a filter or limit condition to limit the data returned. ")
.addContext("You can also try an ODBC/JDBC client. ")
.build(logger);
//Add event
workManager.getBee().getForemanForQueryId(queryId)
.addToEventQueue(QueryState.FAILED,
UserException.resourceError(
new Throwable(
"There is not enough heap memory to run this query using the web interface. "
+ "Please try a query with fewer columns or with a filter or limit condition to limit the data returned. "
+ "You can also try an ODBC/JDBC client. "
)
)
.build(logger)
);
.addToEventQueue(QueryState.FAILED, almostOutOfHeapException);
//Return NearlyOutOfHeap exception
throw almostOutOfHeapException;
}

if (logger.isTraceEnabled()) {
logger.trace("Query {} is completed ", queryId);
logger.trace("Query {} is completed ", queryId);

if (webUserConnection.getError() != null) {
throw new UserRemoteException(webUserConnection.getError());
}

if (webUserConnection.results.isEmpty()) {

0 comments on commit e3534b6

Please sign in to comment.