Repository: tez
Updated Branches:
refs/heads/branch-0.6 addae1646 -> b16b9b1fe
TEZ-814. Improve heuristic for determining a task has failed outputs (bikas)
(cherry picked from commit 94488e79d8d3d73e93337a57a48d82f82182591b)
Conflicts:
CHANGES.txt
(cherry picked from commit 94e256de6dc760c2ae5f17ec4b5a951ca1651118)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/b16b9b1f
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/b16b9b1f
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/b16b9b1f
Branch: refs/heads/branch-0.6
Commit: b16b9b1feb5a46755d98dddf71c6d32160d7af46
Parents: addae16
Author: Bikas Saha <[email protected]>
Authored: Thu Sep 17 23:09:11 2015 -0700
Committer: Bikas Saha <[email protected]>
Committed: Thu Sep 17 23:25:21 2015 -0700
----------------------------------------------------------------------
CHANGES.txt | 2 +
.../apache/tez/dag/api/TezConfiguration.java | 14 ++++++
tez-dag/findbugs-exclude.xml | 1 +
.../tez/dag/app/dag/impl/TaskAttemptImpl.java | 33 +++++++++----
.../tez/dag/app/dag/impl/TestTaskAttempt.java | 49 ++++++++++++++++++--
5 files changed, 86 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tez/blob/b16b9b1f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 61ed5ed..83894a4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,7 @@ Release 0.6.3: Unreleased
INCOMPATIBLE CHANGES
ALL CHANGES:
+ TEZ-814. Improve heuristic for determining a task has failed outputs
TEZ-2809. Minimal distribution compiled on 2.6 fails to run on 2.7
TEZ-2768. Log a useful error message when the summary stream cannot be
closed when shutting
down an AM.
@@ -236,6 +237,7 @@ INCOMPATIBLE CHANGES
TEZ-2552. CRC errors can cause job to run for very long time in large jobs.
ALL CHANGES:
+ TEZ-814. Improve heuristic for determining a task has failed outputs
TEZ-2768. Log a useful error message when the summary stream cannot be
closed when shutting
down an AM.
TEZ-2745. ClassNotFoundException of user code should fail dag
http://git-wip-us.apache.org/repos/asf/tez/blob/b16b9b1f/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
b/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
index c70ba25..2c1d82f 100644
--- a/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
+++ b/tez-api/src/main/java/org/apache/tez/dag/api/TezConfiguration.java
@@ -178,6 +178,20 @@ public class TezConfiguration extends Configuration {
public static final int TEZ_TASK_MAX_ALLOWED_OUTPUT_FAILURES_DEFAULT = 10;
/**
+ * int value. Represents the maximum time in seconds for which a consumer
attempt can report
+ * a read error against its producer attempt, after which the producer
attempt will be re-run
+ * to re-generate the output. There are other heuristics which determine the
retry and mainly
+ * try to guard against a flurry of re-runs due to intermittent read errors
+ * (due to network issues). This configuration puts a time limit on those
heuristics to ensure
+ * jobs dont hang indefinitely due to lack of closure in those heuristics
+ *
+ * Expert level setting.
+ */
+ public static final String TEZ_AM_MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC =
+ TEZ_AM_PREFIX + "max.allowed.time-sec.for-read-error";
+ public static final int
TEZ_AM_MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC_DEFAULT = 300;
+
+ /**
* Boolean value. Determines when the final outputs to data sinks are
committed. Commit is an
* output specific operation and typically involves making the output
visible for consumption.
* If the config is true, then the outputs are committed at the end of DAG
completion after all
http://git-wip-us.apache.org/repos/asf/tez/blob/b16b9b1f/tez-dag/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/tez-dag/findbugs-exclude.xml b/tez-dag/findbugs-exclude.xml
index 0ae5ee6..d82de4d 100644
--- a/tez-dag/findbugs-exclude.xml
+++ b/tez-dag/findbugs-exclude.xml
@@ -28,6 +28,7 @@
<Or>
<Field name="MAX_ALLOWED_OUTPUT_FAILURES_FRACTION"/>
<Field name="MAX_ALLOWED_OUTPUT_FAILURES"/>
+ <Field name="MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC"/>
</Or>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>
http://git-wip-us.apache.org/repos/asf/tez/blob/b16b9b1f/tez-dag/src/main/java/org/apache/tez/dag/app/dag/impl/TaskAttemptImpl.java
----------------------------------------------------------------------
diff --git
a/tez-dag/src/main/java/org/apache/tez/dag/app/dag/impl/TaskAttemptImpl.java
b/tez-dag/src/main/java/org/apache/tez/dag/app/dag/impl/TaskAttemptImpl.java
index 6d9d4ab..7b887a5 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/app/dag/impl/TaskAttemptImpl.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/app/dag/impl/TaskAttemptImpl.java
@@ -108,6 +108,7 @@ import
org.apache.tez.runtime.api.impl.EventMetaData.EventProducerConsumerType;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
public class TaskAttemptImpl implements TaskAttempt,
EventHandler<TaskAttemptEvent> {
@@ -152,10 +153,10 @@ public class TaskAttemptImpl implements TaskAttempt,
Set<String> taskHosts = new HashSet<String>();
Set<String> taskRacks = new HashSet<String>();
- private Set<TezTaskAttemptID> uniquefailedOutputReports =
- new HashSet<TezTaskAttemptID>();
+ private Map<TezTaskAttemptID, Long> uniquefailedOutputReports =
Maps.newHashMap();
private static double MAX_ALLOWED_OUTPUT_FAILURES_FRACTION;
private static int MAX_ALLOWED_OUTPUT_FAILURES;
+ private static int MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC;
protected final boolean isRescheduled;
private final Resource taskResource;
@@ -411,6 +412,10 @@ public class TaskAttemptImpl implements TaskAttempt,
this.MAX_ALLOWED_OUTPUT_FAILURES_FRACTION = conf.getDouble(TezConfiguration
.TEZ_TASK_MAX_ALLOWED_OUTPUT_FAILURES_FRACTION, TezConfiguration
.TEZ_TASK_MAX_ALLOWED_OUTPUT_FAILURES_FRACTION_DEFAULT);
+
+ MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC = conf.getInt(
+ TezConfiguration.TEZ_AM_MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC,
+
TezConfiguration.TEZ_AM_MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC_DEFAULT);
ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
this.readLock = rwLock.readLock();
this.writeLock = rwLock.writeLock();
@@ -1455,7 +1460,17 @@ public class TaskAttemptImpl implements TaskAttempt,
LOG.info(attempt.getID()
+ " blamed for read error from " + failedDestTaId
+ " at inputIndex " + failedInputIndexOnDestTa);
- attempt.uniquefailedOutputReports.add(failedDestTaId);
+ long time = attempt.clock.getTime();
+ Long firstErrReportTime =
attempt.uniquefailedOutputReports.get(failedDestTaId);
+ if (firstErrReportTime == null) {
+ attempt.uniquefailedOutputReports.put(failedDestTaId, time);
+ firstErrReportTime = time;
+ }
+
+ int readErrorTimespanSec = (int)((time - firstErrReportTime)/1000);
+ boolean crossTimeDeadline = readErrorTimespanSec >=
+ MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC ? true : false;
+
float failureFraction = ((float)
attempt.uniquefailedOutputReports.size())
/ outputFailedEvent.getConsumerTaskNumber();
@@ -1467,14 +1482,16 @@ public class TaskAttemptImpl implements TaskAttempt,
// If needed we can launch a background task without failing this task
// to generate a copy of the output just in case.
// If needed we can consider only running consumer tasks
- if (withinFailureFractionLimits && withinOutputFailureLimits) {
+ if (!crossTimeDeadline && withinFailureFractionLimits &&
withinOutputFailureLimits) {
return attempt.getInternalState();
}
String message = attempt.getID() + " being failed for too many output
errors. "
- + "failureFraction=" + failureFraction + ", "
- + "MAX_ALLOWED_OUTPUT_FAILURES_FRACTION=" +
MAX_ALLOWED_OUTPUT_FAILURES_FRACTION + ", "
- + "uniquefailedOutputReports=" +
attempt.uniquefailedOutputReports.size() + ", "
- + "MAX_ALLOWED_OUTPUT_FAILURES=" + MAX_ALLOWED_OUTPUT_FAILURES;
+ + "failureFraction=" + failureFraction
+ + ", MAX_ALLOWED_OUTPUT_FAILURES_FRACTION=" +
MAX_ALLOWED_OUTPUT_FAILURES_FRACTION
+ + ", uniquefailedOutputReports=" +
attempt.uniquefailedOutputReports.size()
+ + ", MAX_ALLOWED_OUTPUT_FAILURES=" + MAX_ALLOWED_OUTPUT_FAILURES
+ + ", MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC=" +
MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC
+ + ", readErrorTimespan=" + readErrorTimespanSec;
LOG.info(message);
attempt.addDiagnosticInfo(message);
// send input failed event
http://git-wip-us.apache.org/repos/asf/tez/blob/b16b9b1f/tez-dag/src/test/java/org/apache/tez/dag/app/dag/impl/TestTaskAttempt.java
----------------------------------------------------------------------
diff --git
a/tez-dag/src/test/java/org/apache/tez/dag/app/dag/impl/TestTaskAttempt.java
b/tez-dag/src/test/java/org/apache/tez/dag/app/dag/impl/TestTaskAttempt.java
index d12412f..1c46eb1 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/dag/impl/TestTaskAttempt.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/dag/impl/TestTaskAttempt.java
@@ -1064,7 +1064,7 @@ public class TestTaskAttempt {
assertEquals(TaskAttemptTerminationCause.UNKNOWN_ERROR,
taImpl.getTerminationCause());
}
- @Test(timeout = 5000)
+ @Test//(timeout = 5000)
// Verifies that multiple TooManyFetchFailures are handled correctly by the
// TaskAttempt.
public void testMultipleOutputFailed() throws Exception {
@@ -1211,15 +1211,54 @@ public class TestTaskAttempt {
//This should fail even when MAX_ALLOWED_OUTPUT_FAILURES_FRACTION is
within limits, as
// MAX_ALLOWED_OUTPUT_FAILURES has crossed the limit.
taImpl2.handle(new TaskAttemptEventOutputFailed(taskAttemptID2, tzEvent,
8));
- assertEquals("Task attempt is not in succeeded state", taImpl2.getState(),
- TaskAttemptState.FAILED);
-
- assertEquals("Task attempt is not in FAILED state", taImpl2.getState(),
+ assertEquals("Task attempt is not in failed state", taImpl2.getState(),
TaskAttemptState.FAILED);
assertEquals(TaskAttemptTerminationCause.OUTPUT_LOST,
taImpl2.getTerminationCause());
// verify unregister is not invoked again
verify(mockHeartbeatHandler, times(1)).unregister(taskAttemptID2);
+ Clock mockClock = mock(Clock.class);
+ int readErrorTimespanSec = 1;
+ taskConf.setInt(TezConfiguration.TEZ_TASK_MAX_ALLOWED_OUTPUT_FAILURES, 10);
+
taskConf.setInt(TezConfiguration.TEZ_AM_MAX_ALLOWED_TIME_FOR_TASK_READ_ERROR_SEC,
readErrorTimespanSec);
+ TezTaskID taskID3 = TezTaskID.getInstance(vertexID, 3);
+ MockTaskAttemptImpl taImpl3 = new MockTaskAttemptImpl(taskID3, 1,
eventHandler,
+ taListener, taskConf, mockClock,
+ mockHeartbeatHandler, appCtx, locationHint, false,
+ resource, createFakeContainerContext(), false);
+ TezTaskAttemptID taskAttemptID3 = taImpl3.getID();
+
+ taImpl3.handle(new TaskAttemptEventSchedule(taskAttemptID3, 0, 0));
+ // At state STARTING.
+ taImpl3.handle(new TaskAttemptEventStartedRemotely(taskAttemptID3, contId,
null));
+ verify(mockHeartbeatHandler).register(taskAttemptID3);
+ taImpl3.handle(new TaskAttemptEvent(taskAttemptID3,
TaskAttemptEventType.TA_DONE));
+ assertEquals("Task attempt is not in succeeded state", taImpl3.getState(),
+ TaskAttemptState.SUCCEEDED);
+ verify(mockHeartbeatHandler).unregister(taskAttemptID3);
+
+ mockReEvent = InputReadErrorEvent.create("", 1, 1);
+ mockMeta = mock(EventMetaData.class);
+ mockDestId1 = mock(TezTaskAttemptID.class);
+ when(mockMeta.getTaskAttemptID()).thenReturn(mockDestId1);
+ tzEvent = new TezEvent(mockReEvent, mockMeta);
+ when(mockClock.getTime()).thenReturn(1000L);
+ // time deadline not exceeded for a couple of read error events
+ taImpl3.handle(new TaskAttemptEventOutputFailed(taskAttemptID3, tzEvent,
1000));
+ assertEquals("Task attempt is not in succeeded state", taImpl3.getState(),
+ TaskAttemptState.SUCCEEDED);
+ when(mockClock.getTime()).thenReturn(1500L);
+ taImpl3.handle(new TaskAttemptEventOutputFailed(taskAttemptID3, tzEvent,
1000));
+ assertEquals("Task attempt is not in succeeded state", taImpl3.getState(),
+ TaskAttemptState.SUCCEEDED);
+ // exceed the time threshold
+ when(mockClock.getTime()).thenReturn(2001L);
+ taImpl3.handle(new TaskAttemptEventOutputFailed(taskAttemptID3, tzEvent,
1000));
+ assertEquals("Task attempt is not in FAILED state", taImpl3.getState(),
+ TaskAttemptState.FAILED);
+ assertEquals(TaskAttemptTerminationCause.OUTPUT_LOST,
taImpl3.getTerminationCause());
+ // verify unregister is not invoked again
+ verify(mockHeartbeatHandler, times(1)).unregister(taskAttemptID3);
}
@SuppressWarnings("deprecation")