### Eclipse Workspace Patch 1.0 #P apache-trunk Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (revision 1429701) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java (working copy) @@ -154,6 +154,8 @@ private final Compactor compactor; + private static final int DEFAULT_FLUSH_TRY_NUM = 5; + /** * Constructor * @param basedir qualified path under which the region directory lives; @@ -693,8 +695,30 @@ // If an exception happens flushing, we let it out without clearing // the memstore snapshot. The old snapshot will be returned when we say // 'snapshot', the next time flush comes around. - return internalFlushCache( - snapshot, logCacheFlushId, snapshotTimeRangeTracker, flushedSize, status); + // Retry after catching exception when flushing, otherwise server will abort + // itself + IOException lastException = null; + for (int i = 0; i < DEFAULT_FLUSH_TRY_NUM; i++) { + try { + Path pathName = internalFlushCache(snapshot, logCacheFlushId, + snapshotTimeRangeTracker, flushedSize, status); + try { + // Path name is null if there is no entries to flush + if (pathName != null) { + validateStoreFile(pathName); + } + return pathName; + } catch (Exception e) { + LOG.warn("Failed validating store file " + pathName + + ", retring num=" + i, e); + lastException = new IOException(e); + } + } catch (IOException e) { + LOG.warn("Failed flushing store file, retring num=" + i, e); + lastException = e; + } + } + throw lastException; } /* @@ -816,7 +840,6 @@ // Write-out finished successfully, move into the right spot String fileName = path.getName(); Path dstPath = new Path(homedir, fileName); - validateStoreFile(path); String msg = "Renaming flushed file at " + path + " to " + dstPath; LOG.debug(msg); status.setStatus("Flushing " + this + ": " + msg);