diff --git a/CHANGES.txt b/CHANGES.txt index 33d38a6c50d..bb2674b0756 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -142,6 +142,7 @@ Release 0.90.2 - Unreleased IMPROVEMENTS HBASE-3542 MultiGet methods in Thrift + HBASE-3285 Hlog recovery takes too much time Release 0.90.1 - Unreleased diff --git a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 48cbaad35d8..dbe935dc660 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -43,6 +43,8 @@ import java.io.DataInputStream; import java.io.EOFException; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InterruptedIOException; +import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -631,8 +633,23 @@ public class FSUtils { boolean recovered = false; while (!recovered) { try { - FSDataOutputStream out = fs.append(p); - out.close(); + try { + if (fs instanceof DistributedFileSystem) { + DistributedFileSystem dfs = (DistributedFileSystem)fs; + DistributedFileSystem.class.getMethod("recoverLease", + new Class[] {Path.class}).invoke(dfs, p); + } else { + throw new Exception("Not a DistributedFileSystem"); + } + } catch (InvocationTargetException ite) { + // function was properly called, but threw it's own exception + throw (IOException) ite.getCause(); + } catch (Exception e) { + LOG.debug("Failed fs.recoverLease invocation, " + e.toString() + + ", trying fs.append instead"); + FSDataOutputStream out = fs.append(p); + out.close(); + } recovered = true; } catch (IOException e) { e = RemoteExceptionHandler.checkIOException(e); @@ -646,11 +663,6 @@ public class FSUtils { LOG.warn("Waited " + waitedFor + "ms for lease recovery on " + p + ":" + e.getMessage()); } - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - // ignore it and try again - } } else if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) { // This exception comes out instead of FNFE, fix it @@ -660,8 +672,12 @@ public class FSUtils { throw new IOException("Failed to open " + p + " for append", e); } } + try { + Thread.sleep(1000); + } catch (InterruptedException ex) { + new InterruptedIOException().initCause(ex); + } } LOG.info("Finished lease recover attempt for " + p); } - }