You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/05/31 20:18:19 UTC

svn commit: r1488343 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/regionserver/Store.java test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java

Author: liyin
Date: Fri May 31 18:18:19 2013
New Revision: 1488343

URL: http://svn.apache.org/r1488343
Log:
[HBASE-8185] ReadOnlyStore should throw when it finds inconsistent region directories.

Author: manukranthk

Summary: ReadOnlyStore should throw an exception when it finds that the region directory is not found. Currently it creates a new directory with that name and continues, which is a valid behavior for a Store but not a valid behavior for ReadOnlyStore.

Test Plan: Unit Testing

Reviewers: liyintang, rshroff, aaiyer

Reviewed By: aaiyer

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D829510

Task ID: 2446974

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=1488343&r1=1488342&r2=1488343&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java Fri May 31 18:18:19 2013
@@ -200,9 +200,16 @@ public class Store extends SchemaConfigu
     this.fs = fs;
     this.homedir = Store.getStoreHomedir(basedir, info.getEncodedName(), family.getName());
     if (!this.fs.exists(this.homedir)) {
-      LOG.info("No directory exists for family " + family + "; creating one");
-      if (!this.fs.mkdirs(this.homedir))
-        throw new IOException("Failed create of: " + this.homedir.toString());
+      LOG.info("No directory exists for family " + family);
+      // region being null is the case where we are creating a read only store.
+      if (region != null) {
+        LOG.info("Creating one");
+        if (!this.fs.mkdirs(this.homedir))
+          throw new IOException("Failed create of: " + this.homedir.toString());
+      } else {
+        throw new IOException("Failed create a read only store. " +
+            "Possibly an inconsistent region");
+      }
     }
     this.family = family;
     // 'conf' renamed to 'confParam' b/c we use this.conf in the constructor

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java?rev=1488343&r1=1488342&r2=1488343&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestClientLocalScanner.java Fri May 31 18:18:19 2013
@@ -79,6 +79,29 @@ public class TestClientLocalScanner {
   }
 
   @Test
+  public void testInconsistentRegionDirectories() throws IOException {
+    byte [] tableName = Bytes.toBytes("testInconsistentRegionDirectories");
+    String rootDir = TEST_UTIL.getConfiguration().get("hbase.rootdir");
+    String tmpPath = "/tmp/testInconsistentRegionDirectories/";
+    FileSystem fs = FileSystem.get(TEST_UTIL.getConfiguration());
+    Path p = new Path(tmpPath);
+    fs.mkdirs(p);
+    assertTrue(fs.listStatus(p).length == 0);
+    TEST_UTIL.getConfiguration().set("hbase.rootdir", tmpPath);
+    HTable t = TEST_UTIL.createTable(tableName, FAMILY);
+    TEST_UTIL.loadTable(t, FAMILY);
+    try {
+      t.getLocalScanner(new Scan());
+    } catch (IOException e) {
+      assertTrue(fs.listStatus(p).length == 0);
+      return;
+    } finally {
+      TEST_UTIL.getConfiguration().set("hbase.rootdir", rootDir);
+    }
+    assertTrue(false);
+  }
+
+  @Test
   public void testCompareLocalScanToRemoteScan() throws IOException {
     byte [] name = Bytes.toBytes("testCompareLocalScanToRemoteScan");
     HTable t = TEST_UTIL.createTable(name, new byte[][] {FAMILY, FAMILY2});