Repository: hbase
Updated Branches:
  refs/heads/branch-1 7c2525bf1 -> cc750c656


HBASE-13331 Exceptions from DFS client can cause CatalogJanitor to delete 
referenced files

Summary:
CatalogJanitor#checkDaughterInFs assumes that there are no references
whenever HRegionFileSystem.openRegionFromFileSystem throws IOException.
Well Hadoop and HBase throw IOExceptions whenever someone looks in their 
general direction.

This patch explicitly checks if the directory exists. If it doesn't then it 
allows references to be
deleted. All other exceptions cause CatalogJanitor to assume there are 
references

Test Plan: Unit tests.

Differential Revision: https://reviews.facebook.net/D35829


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cc750c65
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cc750c65
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cc750c65

Branch: refs/heads/branch-1
Commit: cc750c656a037643dab941444a64abd790907e4b
Parents: 7c2525b
Author: Elliott Clark <[email protected]>
Authored: Tue Mar 24 13:42:29 2015 -0700
Committer: Elliott Clark <[email protected]>
Committed: Tue Mar 24 19:52:17 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/master/CatalogJanitor.java      | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cc750c65/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
index 9d18c98..6db7802 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
@@ -369,14 +369,27 @@ public class CatalogJanitor extends ScheduledChore {
     Path rootdir = this.services.getMasterFileSystem().getRootDir();
     Path tabledir = FSUtils.getTableDir(rootdir, daughter.getTable());
 
+    Path daughterRegionDir = new Path(tabledir, daughter.getEncodedName());
+
     HRegionFileSystem regionFs = null;
+
+    try {
+      if (!FSUtils.isExists(fs, daughterRegionDir)) {
+        return new Pair<Boolean, Boolean>(Boolean.FALSE, Boolean.FALSE);
+      }
+    } catch (IOException ioe) {
+      LOG.warn("Error trying to determine if daughter region exists, " +
+               "assuming exists and has references", ioe);
+      return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.TRUE);
+    }
+
     try {
       regionFs = HRegionFileSystem.openRegionFromFileSystem(
           this.services.getConfiguration(), fs, tabledir, daughter, true);
     } catch (IOException e) {
-      LOG.warn("Daughter region does not exist: " + daughter.getEncodedName()
-        + ", parent is: " + parent.getEncodedName());
-      return new Pair<Boolean, Boolean>(Boolean.FALSE, Boolean.FALSE);
+      LOG.warn("Error trying to determine referenced files from : " + 
daughter.getEncodedName()
+          + ", to: " + parent.getEncodedName() + " assuming has references", 
e);
+      return new Pair<Boolean, Boolean>(Boolean.TRUE, Boolean.TRUE);
     }
 
     boolean references = false;

Reply via email to