Skip to content

Commit

Permalink
Merge d42405e into 3bdf121
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalperi committed Jun 5, 2014
2 parents 3bdf121 + d42405e commit a29c5f7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/edu/washington/escience/myria/operator/Apply.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void setEmitExpressions(final List<Expression> emitExpressions) {
protected TupleBatch fetchNextReady() throws DbException, InvocationTargetException {
Operator child = getChild();

if (child.eoi() || getChild().eos()) {
if (child.eoi() || child.eos()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void operationComplete(final LocalSubQueryFuture future) throws Exception
queryExecutionFuture.setFailure(new QueryKilledException());
} else {
DbException composedException =
new DbException("Query #" + future.getLocalSubQuery().getSubQueryId() + " failed.");
new DbException("Query #" + future.getLocalSubQuery().getSubQueryId() + " failed");
for (Entry<Integer, Throwable> workerIDCause : failedWorkerLocalSubQueries.entrySet()) {
int failedWorkerID = workerIDCause.getKey();
Throwable cause = workerIDCause.getValue();
Expand Down
23 changes: 20 additions & 3 deletions src/edu/washington/escience/myria/parallel/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import javax.annotation.concurrent.GuardedBy;

import org.slf4j.LoggerFactory;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
Expand All @@ -14,11 +16,14 @@
import edu.washington.escience.myria.api.encoding.QueryEncoding;
import edu.washington.escience.myria.api.encoding.QueryStatusEncoding;
import edu.washington.escience.myria.api.encoding.QueryStatusEncoding.Status;
import edu.washington.escience.myria.util.ErrorUtils;

/**
* Keeps track of all the state (statistics, subqueries, etc.) for a single Myria query.
*/
public final class Query {
/** The logger for this class. */
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Query.class);
/** The id of this query. */
private final long queryId;
/** The id of the next subquery to be issued. */
Expand All @@ -37,6 +42,7 @@ public final class Query {
/** The server. */
private final Server server;
/** The message explaining why a query failed. */
@GuardedBy("this")
private String message;
/** The future for this query. */
private final QueryFuture future;
Expand Down Expand Up @@ -155,6 +161,9 @@ public String getStartTime() {
* Set the time this query started to now in ISO8601 format.
*/
public void markStart() {
synchronized (this) {
status = Status.RUNNING;
}
executionStats.markStart();
}

Expand All @@ -165,11 +174,17 @@ public void markStart() {
*/
public void markFailed(final Throwable cause) {
Preconditions.checkNotNull(cause, "cause");
markEnd();
synchronized (this) {
if (status == Status.ERROR || status == Status.SUCCESS || status == Status.KILLED) {
LOGGER.warn("Ignoring markFailed(cause) because already have status {}, message {}", status, message, cause);
return;
}
status = Status.ERROR;
}
message = cause.getMessage();
markEnd();
synchronized (this) {
message = ErrorUtils.getStackTrace(cause);
}
future.setException(cause);
}

Expand Down Expand Up @@ -216,7 +231,9 @@ public Long getElapsedTime() {
* @return a message explaining why a query failed, or <code>null</code> if the query did not fail
*/
public String getMessage() {
return message;
synchronized (this) {
return message;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package edu.washington.escience.myria.systemtest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.net.HttpURLConnection;
import java.util.HashMap;
Expand Down Expand Up @@ -64,6 +66,7 @@
import edu.washington.escience.myria.parallel.SubQueryPlan;
import edu.washington.escience.myria.storage.TupleBatch;
import edu.washington.escience.myria.storage.TupleBatchBuffer;
import edu.washington.escience.myria.util.ErrorUtils;
import edu.washington.escience.myria.util.JsonAPIUtils;

public class SequenceTest extends SystemTestBase {
Expand Down Expand Up @@ -156,7 +159,19 @@ public void testSequenceFailSubQuery2() throws Exception {
QueryFuture qf = server.submitQuery(encoding, all);

/* Wait for query to finish, expecting an exception. */
qf.get();
try {
qf.get();
} catch (Exception e) {
/*
* Assert both 1) that the cause of the exception is in the stack trace and 2) that this message is visible via
* the API. See https://github.com/uwescience/myria/issues/542
*/
assertTrue(ErrorUtils.getStackTrace(e).contains("Failure in init"));
String message = server.getQueryStatus(qf.getQueryId()).message;
assertNotNull(message);
assertTrue(message.contains("Failure in init"));
throw e;
}
}

@Test
Expand Down

0 comments on commit a29c5f7

Please sign in to comment.