[ https://issues.apache.org/jira/browse/HADOOP-2292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546015 ]
Jim Kellerman commented on HADOOP-2292: --------------------------------------- all of the table operations (except createTableAsync) are "semi-synchronous", meaning that they wait until the first region in the table changes state and then they return letting the rest of the table be updated in the background. (Of course createTable only deals with one region so it is completely synchronous). The reasons for semi synchronous operation are: - such an operation on a large table could take a long time to complete - it is likely that the rpc would timeout before the operation completed. Using Thread.sleep could be unreliable as these operations take an indeterminate amount of time. What you might do is open a HTable on the META region (HConstants.META_TABLE_NAME) and scan HConstants.COL_REGIONINFO_ARRAY which will give you back HRegionInfo objects (as bytes). Find the table in question by comparing your table name to regionInfo.getTableDesc().getName() If adding or deleting columns, check regionInfo.getTableDesc().hasFamily() If changing table on/off line check regionInfo.isOffline() If any of the regions don't meet the criteria, close the scanner, sleep and rescan. > HBaseAdmin.disableTable/enableTable aren't synchronous > ------------------------------------------------------ > > Key: HADOOP-2292 > URL: https://issues.apache.org/jira/browse/HADOOP-2292 > Project: Hadoop > Issue Type: Bug > Components: contrib/hbase > Affects Versions: 0.15.0 > Reporter: Michael Bieniosek > > I'm trying to programmatically add a column family to a table. > I have code that looks like: > <code> > admin.disableTable(table); > try { > admin.addColumn(table, new HColumnDescriptor(columnName)); > } finally { > admin.enableTable(table); > } > HTable ht = new HTable(config, table); > <code> > Two things sometimes go wrong here: > 1. addColumn fails because the table is not disabled > 2. new HTable() fails because the table is not enabled > I suspect that the enableTable/disableTable calls are not synchronous, ie. > they return before they are finished. I can work around this problem by > inserting Thread.sleeps after the enableTable and disableTable calls. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.