Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-10628 Fix semantic inconsistency among methods which are exposed to client
  3. HBASE-10584

Inconsistency between tableExists and listTables in implementation

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Abandoned
    • None
    • None
    • Client, master
    • None

    Description

      1. HBaseAdmin.tableExists is implemented by scanning meta table
      2. HBaseAdmin.listTables(and HBaseAdmin.getTableDescriptor) is implemented by talking with HMaster which responses by querying the FSTableDescriptors, and FSTableDescriptors return all tables by scanning all the table descriptor files in FS(cache also plays here, so most of time it can be satisfied by cache)...

      Actually HBaseAdmin requests HMaster to check if a table exists internally when implementing deleteTable(see below), then why does it use a different(scanning meta table) way to implementing tableExists() for outside user to use for the same purpose?

        tableExists = false;
        GetTableDescriptorsResponse htds;
        MasterKeepAliveConnection master = connection.getKeepAliveMasterService();
        try {
          GetTableDescriptorsRequest req =
          RequestConverter.buildGetTableDescriptorsRequest(tableName);
          htds = master.getTableDescriptors(null, req);
        } catch (ServiceException se) {
          throw ProtobufUtil.getRemoteException(se);
        } finally {
          master.close();
        }
        tableExists = !htds.getTableSchemaList().isEmpty();
      

      (Above verifying that table descriptor file is deleted can guarantee all items of this table are deleted from meta table...)

      Since creating table descriptor files and inserting item to meta table occur in different time without atomic semantic, this inconsistency in implementation can lead to confusing behaviors when create-table or delete-table fails midway, (before according cleanup is done) table descriptor file may exists while no item exists in meta table (for create-table where table descriptor file is created before inserting item to meta table), this leads to listTables including that table, while tableExists says no. Similar inconsistency if delete-table fails mid-way...

      Confusing behavior can happen during the process even though eventually it succeed:

      1. During table creation, when a user calls listTables and then calls tableExists for this table after the table descriptor is created but before item is inserted to meta table. He will find the listTables includes a table but tableExists return false for that same table, this behavior is confusing and should only acceptable during the table is being deleted...
      2. Similar behavior occurs during table deletion.

      Seems the benefit of implementing tableExists this way is we can avoid talking with HMaster, considering we talk with HMaster for listTables and getTableDescriptor, such benefit can't offset the drawback from inconsistency.

      Attachments

        1. HBASE-10584-trunk_v1.patch
          2 kB
          Honghua Feng
        2. HBASE-10584-trunk_v1.patch
          2 kB
          Michael Stack

        Issue Links

          Activity

            People

              Unassigned Unassigned
              fenghh Honghua Feng
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: