Skip to content

Commit

Permalink
DRILL-6591: Show Exception for failed queries submitted in WebUI
Browse files Browse the repository at this point in the history
When query fails on Web UI result page no error is shown, only "No result found." 
This was because DRILL-6477 (PR apache#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 add a new WebUser-only method - `WebUserConnection.timedWait(long timeoutInMillis)` 
This ensures that other callers to the `WebUserConnection.await(timeoutInMillis)` is unaffected.
  • Loading branch information
kkhatua committed Jul 13, 2018
1 parent eb90ebd commit 282a217
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
Expand Up @@ -54,6 +54,19 @@ public boolean await(final long timeoutMillis) throws InterruptedException {
return latch.await(timeoutMillis, TimeUnit.MILLISECONDS);
}

/**
* Wait until the query has completed or timeout is passed. (Used only in case of WebUser)
*
* @throws Exception
*/
public boolean timedWait(final long timeoutMillis) throws Exception {
boolean status = latch.await(timeoutMillis, TimeUnit.MILLISECONDS);
if (exception != null) {
throw exception;
}
return status;
}

/**
* Wait indefinitely until the query is completed. Used only in case of WebUser
*
Expand Down
Expand Up @@ -83,12 +83,17 @@ public QueryResult run(final WorkManager workManager, final WebUserConnection we
float usagePercent = getHeapUsage();

// Wait until the query execution is complete or there is error submitting the query
logger.debug("Wait until the query execution is complete or there is error submitting the query");
if (logger.isDebugEnabled()) {
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.timedWait(TimeUnit.SECONDS.toMillis(1)); /*periodically timeout 1sec to check heap */
} catch (Exception e) { /* Timed Out => Check usage */
if (e instanceof UserException) { //Throw UserException only
throw e;
}
}
usagePercent = getHeapUsage();
if (usagePercent > HEAP_MEMORY_FAILURE_THRESHOLD) {
nearlyOutOfHeapSpace = true;
Expand All @@ -97,17 +102,19 @@ public QueryResult run(final WorkManager workManager, final WebUserConnection we

//Fail if nearly out of heap space
if (nearlyOutOfHeapSpace) {
UserException almostOutOfHeapException = 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);
//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()) {
Expand Down

0 comments on commit 282a217

Please sign in to comment.