Browse Source

HADOOP-3166. Fix an ArrayIndexOutOfBoundsException in the spill thread
and make exception handling more promiscuous to catch similar conditions.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@644903 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 years ago
parent
commit
7272a9789b
2 changed files with 13 additions and 7 deletions
  1. 4 0
      CHANGES.txt
  2. 9 7
      src/java/org/apache/hadoop/mapred/MapTask.java

+ 4 - 0
CHANGES.txt

@@ -498,6 +498,10 @@ Trunk (unreleased changes)
     HADOOP-3083. The fsimage does not store leases. This would have to be
     reworked in the next release to support appends. (dhruba)
 
+    HADOOP-3166. Fix an ArrayIndexOutOfBoundsException in the spill thread
+    and make exception handling more promiscuous to catch this condition.
+    (cdouglas)
+
 Release 0.16.3 - Unreleased
 
   BUG FIXES

+ 9 - 7
src/java/org/apache/hadoop/mapred/MapTask.java

@@ -312,7 +312,7 @@ class MapTask extends Task {
 
     // spill accounting
     private volatile int numSpills = 0;
-    private volatile IOException sortSpillException = null;
+    private volatile Throwable sortSpillException = null;
     private final int softRecordLimit;
     private final int softBufferLimit;
     private final Object spillLock = new Object();
@@ -424,7 +424,8 @@ class MapTask extends Task {
                               + value.getClass().getName());
       }
       if (sortSpillException != null) {
-        throw sortSpillException;
+        throw (IOException)new IOException("Spill failed"
+            ).initCause(sortSpillException);
       }
       try {
         int keystart = bufindex;
@@ -588,8 +589,8 @@ class MapTask extends Task {
         synchronized(spillLock) {
           do {
             if (sortSpillException != null) {
-              throw (IOException)new IOException().initCause(
-                  sortSpillException);
+              throw (IOException)new IOException("Spill failed"
+                  ).initCause(sortSpillException);
             }
 
             // sufficient accounting space?
@@ -679,7 +680,8 @@ class MapTask extends Task {
         }
       }
       if (sortSpillException != null) {
-        throw (IOException)new IOException().initCause(sortSpillException);
+        throw (IOException)new IOException("Spill failed"
+            ).initCause(sortSpillException);
       }
       if (kvend != kvindex) {
         kvend = kvindex;
@@ -698,7 +700,7 @@ class MapTask extends Task {
       public void run() {
         try {
           sortAndSpill();
-        } catch (IOException e) {
+        } catch (Throwable e) {
           sortSpillException = e;
         } finally {
           synchronized(spillLock) {
@@ -850,7 +852,7 @@ class MapTask extends Task {
     private void getVBytesForOffset(int kvoff, InMemValBytes vbytes) {
       final int nextindex = kvoff / ACCTSIZE == kvend - 1
         ? bufend
-        : kvindices[kvoff + ACCTSIZE + KEYSTART];
+        : kvindices[(kvoff + ACCTSIZE + KEYSTART) % kvindices.length];
       int vallen = (nextindex > kvindices[kvoff + VALSTART])
         ? nextindex - kvindices[kvoff + VALSTART]
         : (bufvoid - kvindices[kvoff + VALSTART]) + nextindex;