Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1327184) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -766,6 +766,16 @@ // and then create the file Path tmpPath = new Path(getTmpDir(), REGIONINFO_FILE); + + // if datanode crashes while trying to close the created regioninfo file + // in the .tmp directory then on next time creation we will be getting + // AlreadyCreatedException. Hence delete and create the file if exists. + if (fs.exists(tmpPath)) { + LOG.debug("Existing '.tmp' regioninfo file " + tmpPath + + " present. Deleting it."); + fs.delete(tmpPath, true); + } + FSDataOutputStream out = FSUtils.create(fs, tmpPath, perms); try {