HBASE-10215 TableNotFoundException should be thrown after removing stale znode in ETH

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1553308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rajeshbabu 2013-12-24 18:03:19 +00:00
parent f23ae335a4
commit c78f1e511b
3 changed files with 39 additions and 2 deletions

View File

@ -2714,8 +2714,15 @@ public class AssignmentManager extends ZooKeeperListener {
+ " to ENABLED state."); + " to ENABLED state.");
// enableTable in sync way during master startup, // enableTable in sync way during master startup,
// no need to invoke coprocessor // no need to invoke coprocessor
new EnableTableHandler(this.server, tableName, EnableTableHandler eth = new EnableTableHandler(this.server, tableName,
catalogTracker, this, tableLockManager, true).prepare().process(); catalogTracker, this, tableLockManager, true);
try {
eth.prepare();
} catch (TableNotFoundException e) {
LOG.warn("Table " + tableName + " not found in hbase:meta to recover.");
continue;
}
eth.process();
} }
} }
} }

View File

@ -91,6 +91,7 @@ public class EnableTableHandler extends EventHandler {
} }
try { try {
this.assignmentManager.getZKTable().removeEnablingTable(tableName, true); this.assignmentManager.getZKTable().removeEnablingTable(tableName, true);
throw new TableNotFoundException(tableName);
} catch (KeeperException e) { } catch (KeeperException e) {
// TODO : Use HBCK to clear such nodes // TODO : Use HBCK to clear such nodes
LOG.warn("Failed to delete the ENABLING node for the table " + tableName LOG.warn("Failed to delete the ENABLING node for the table " + tableName

View File

@ -947,6 +947,35 @@ public class TestAssignmentManager {
} }
} }
/**
* Test verifies whether stale znodes of unknown tables as for the hbase:meta will be removed or
* not.
* @throws KeeperException
* @throws IOException
* @throws Exception
*/
@Test
public void testMasterRestartShouldRemoveStaleZnodesOfUnknownTableAsForMeta()
throws KeeperException, IOException, Exception {
List<ServerName> destServers = new ArrayList<ServerName>(1);
destServers.add(SERVERNAME_A);
Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
Server server = new HMaster(HTU.getConfiguration());
Whitebox.setInternalState(server, "serverManager", this.serverManager);
AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
this.serverManager);
try {
TableName tableName = TableName.valueOf("dummyTable");
// set table in enabling state.
am.getZKTable().setEnablingTable(tableName);
am.joinCluster();
assertFalse("Table should not be present in zookeeper.",
am.getZKTable().isTablePresent(tableName));
} finally {
}
}
/** /**
* When a region is in transition, if the region server opening the region goes down, * When a region is in transition, if the region server opening the region goes down,
* the region assignment takes a long time normally (waiting for timeout monitor to trigger assign). * the region assignment takes a long time normally (waiting for timeout monitor to trigger assign).