HBASE-2065 Cannot disable a table if any of its region is opening at the same time
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@893675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b3748a994
commit
69b1be1d50
|
@ -326,15 +326,16 @@ public class HBaseAdmin {
|
|||
if (this.master == null) {
|
||||
throw new MasterNotRunningException("master has been shut down");
|
||||
}
|
||||
try {
|
||||
this.master.enableTable(tableName);
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
}
|
||||
|
||||
// Wait until all regions are enabled
|
||||
boolean enabled = false;
|
||||
for (int tries = 0; tries < this.numRetries; tries++) {
|
||||
|
||||
try {
|
||||
this.master.enableTable(tableName);
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
}
|
||||
enabled = isTableEnabled(tableName);
|
||||
if (enabled) break;
|
||||
long sleep = getPauseTime(tries);
|
||||
|
@ -382,15 +383,15 @@ public class HBaseAdmin {
|
|||
if (this.master == null) {
|
||||
throw new MasterNotRunningException("master has been shut down");
|
||||
}
|
||||
try {
|
||||
this.master.disableTable(tableName);
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
}
|
||||
|
||||
// Wait until all regions are disabled
|
||||
boolean disabled = false;
|
||||
for (int tries = 0; tries < this.numRetries; tries++) {
|
||||
try {
|
||||
this.master.disableTable(tableName);
|
||||
} catch (RemoteException e) {
|
||||
throw RemoteExceptionHandler.decodeRemoteException(e);
|
||||
}
|
||||
disabled = isTableDisabled(tableName);
|
||||
if (disabled) break;
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
|
|
@ -78,6 +78,13 @@ class ChangeTableState extends TableOperation {
|
|||
continue;
|
||||
}
|
||||
|
||||
if(!this.online && this.master.getRegionManager().
|
||||
isPendingOpen(i.getRegionNameAsString())) {
|
||||
LOG.debug("Skipping region " + i.toString() +
|
||||
" because it is pending open, will tell it to close later");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update meta table
|
||||
Put put = updateRegionInfo(i);
|
||||
server.put(m.getRegionName(), put);
|
||||
|
|
|
@ -59,11 +59,11 @@ class ProcessRegionClose extends ProcessRegionStatusChange {
|
|||
@Override
|
||||
protected boolean process() throws IOException {
|
||||
Boolean result = null;
|
||||
if (offlineRegion) {
|
||||
if (offlineRegion || reassignRegion) {
|
||||
result =
|
||||
new RetryableMetaOperation<Boolean>(getMetaRegion(), this.master) {
|
||||
public Boolean call() throws IOException {
|
||||
LOG.info("region closed: " + regionInfo.getRegionNameAsString());
|
||||
|
||||
|
||||
// We can't proceed unless the meta region we are going to update
|
||||
// is online. metaRegionAvailable() will put this operation on the
|
||||
|
@ -71,21 +71,27 @@ class ProcessRegionClose extends ProcessRegionStatusChange {
|
|||
// back on the toDoQueue
|
||||
|
||||
if (metaRegionAvailable()) {
|
||||
// offline the region in meta and then remove it from the
|
||||
// set of regions in transition
|
||||
HRegion.offlineRegionInMETA(server, metaRegionName,
|
||||
regionInfo);
|
||||
master.getRegionManager().removeRegion(regionInfo);
|
||||
if(offlineRegion) {
|
||||
// offline the region in meta and then remove it from the
|
||||
// set of regions in transition
|
||||
HRegion.offlineRegionInMETA(server, metaRegionName,
|
||||
regionInfo);
|
||||
master.getRegionManager().removeRegion(regionInfo);
|
||||
LOG.info("region closed: " + regionInfo.getRegionNameAsString());
|
||||
} else {
|
||||
// we are reassigning the region eventually, so set it unassigned
|
||||
// and remove the server info
|
||||
HRegion.cleanRegionInMETA(server, metaRegionName,
|
||||
regionInfo);
|
||||
master.getRegionManager().setUnassigned(regionInfo, false);
|
||||
LOG.info("region set as unassigned: " + regionInfo.getRegionNameAsString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}.doWithRetries();
|
||||
result = result == null ? true : result;
|
||||
|
||||
} else if (reassignRegion) {
|
||||
LOG.info("region set as unassigned: " + regionInfo.getRegionNameAsString());
|
||||
// we are reassigning the region eventually, so set it unassigned
|
||||
master.getRegionManager().setUnassigned(regionInfo, false);
|
||||
} else {
|
||||
LOG.info("Region was neither offlined, or asked to be reassigned, what gives: " +
|
||||
regionInfo.getRegionNameAsString());
|
||||
|
|
|
@ -1925,9 +1925,7 @@ public class HRegion implements HConstants, HeapSize { // , Writable{
|
|||
|
||||
/**
|
||||
* Delete a region's meta information from the passed
|
||||
* <code>meta</code> region. Removes content in the 'info' column family.
|
||||
* Does not remove region historian info.
|
||||
*
|
||||
* <code>meta</code> region. Deletes the row.
|
||||
* @param srvr META server to be updated
|
||||
* @param metaRegionName Meta region name
|
||||
* @param regionName HRegion to remove from <code>meta</code>
|
||||
|
@ -1938,7 +1936,6 @@ public class HRegion implements HConstants, HeapSize { // , Writable{
|
|||
final byte [] metaRegionName, final byte [] regionName)
|
||||
throws IOException {
|
||||
Delete delete = new Delete(regionName);
|
||||
delete.deleteFamily(HConstants.CATALOG_FAMILY);
|
||||
srvr.delete(metaRegionName, delete);
|
||||
}
|
||||
|
||||
|
@ -1961,10 +1958,7 @@ public class HRegion implements HConstants, HeapSize { // , Writable{
|
|||
info.setOffline(true);
|
||||
put.add(CATALOG_FAMILY, REGIONINFO_QUALIFIER, Writables.getBytes(info));
|
||||
srvr.put(metaRegionName, put);
|
||||
Delete del = new Delete(row);
|
||||
del.deleteColumns(CATALOG_FAMILY, SERVER_QUALIFIER);
|
||||
del.deleteColumns(CATALOG_FAMILY, STARTCODE_QUALIFIER);
|
||||
srvr.delete(metaRegionName, del);
|
||||
cleanRegionInMETA(srvr, metaRegionName, info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -395,7 +395,6 @@ public class TestAdmin {
|
|||
@Test
|
||||
public void testHundredsOfTable() throws IOException{
|
||||
final int times = 100;
|
||||
byte [] name = Bytes.toBytes("testHundredsOfTable");
|
||||
HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
|
||||
HColumnDescriptor fam2 = new HColumnDescriptor("fam2");
|
||||
HColumnDescriptor fam3 = new HColumnDescriptor("fam3");
|
||||
|
@ -411,6 +410,8 @@ public class TestAdmin {
|
|||
for(int i = 0; i < times; i++) {
|
||||
String tableName = "table"+i;
|
||||
this.admin.disableTable(tableName);
|
||||
this.admin.enableTable(tableName);
|
||||
this.admin.disableTable(tableName);
|
||||
this.admin.deleteTable(tableName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue