Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-6576

HBaseAdmin.createTable should wait until the table is enabled

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.94.2
    • Client, test
    • None
    • Reviewed

    Description

      The function:

      public void createTable(final HTableDescriptor desc, byte [][] splitKeys)
      

      in HBaseAdmin is synchronous and returns once all the regions of the table are online, but does not wait for the table to be enabled, which is the last step of table creation (see CreateTableHandler).

      This is confusing and leads to racy code because users do not realize that this is the case. For example, I saw the following test failure in 0.92 when I ran:
      mvn test -Dtest=org.apache.hadoop.hbase.client.TestAdmin#testEnableDisableAddColumnDeleteColumn

      Error Message
      
      org.apache.hadoop.hbase.TableNotEnabledException: testMasterAdmin at org.apache.hadoop.hbase.master.handler.DisableTableHandler.<init>(DisableTableHandler.java:75) at org.apache.hadoop.hbase.master.HMaster.disableTable(HMaster.java:1154) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:364) at org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1336)
      
      Stacktrace
      
      org.apache.hadoop.hbase.TableNotEnabledException: org.apache.hadoop.hbase.TableNotEnabledException: testMasterAdmin
      at org.apache.hadoop.hbase.master.handler.DisableTableHandler.<init>(DisableTableHandler.java:75)
      at org.apache.hadoop.hbase.master.HMaster.disableTable(HMaster.java:1154)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:364)
      at org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1336)
      

      The issue is that code will create and table and immediately disable it in order to do some testing, for example, to test an operation that only works when the table is disabled. If the table has not been enabled yet, they will get back a TableNotEnabledException.

      The specific test above was fixed in HBASE-5206, but other examples exist in the code, for example the following:

      hbase org.apache.hadoop.hbase.mapreduce.TestHFileOutputFormat newtable asdf14
      

      The code in question is:

      byte[] tname = args[1].getBytes();
      HTable table = util.createTable(tname, FAMILIES);
      HBaseAdmin admin = new HBaseAdmin(conf);
      admin.disableTable(tname);
      

      It would be better if createTable just waited until the table was enabled, or threw a TableNotEnabledException if it exhausted the configured number of retries.

      Attachments

        1. HBASE-6576-trunk.patch
          5 kB
          Gregory Chanan
        2. HBASE-6576-94.patch
          5 kB
          Gregory Chanan
        3. HBASE-6576-92.patch
          5 kB
          Gregory Chanan

        Activity

          People

            gchanan Gregory Chanan
            gchanan Gregory Chanan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: