HBASE-8899 Could not open a region on a server where it is being closed
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1501464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6665054ef
commit
c4b775eb17
|
@ -118,7 +118,6 @@ import org.apache.hadoop.hbase.ipc.ServerRpcController;
|
|||
import org.apache.hadoop.hbase.master.SplitLogManager;
|
||||
import org.apache.hadoop.hbase.master.TableLockManager;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.ReplicationProtbufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
||||
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
|
||||
|
@ -3414,10 +3413,18 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
Pair<HRegionInfo, ServerName> p = MetaReader.getRegion(
|
||||
this.catalogTracker, region.getRegionName());
|
||||
if (this.getServerName().equals(p.getSecond())) {
|
||||
LOG.warn("Attempted open of " + region.getEncodedName()
|
||||
Boolean closing = regionsInTransitionInRS.get(region.getEncodedNameAsBytes());
|
||||
// Map regionsInTransitionInRSOnly has an entry for a region only if the region
|
||||
// is in transition on this RS, so here closing can be null. If not null, it can
|
||||
// be true or false. True means the region is opening on this RS; while false
|
||||
// means the region is closing. Only return ALREADY_OPENED if not closing (i.e.
|
||||
// not in transition any more, or still transition to open.
|
||||
if (!Boolean.FALSE.equals(closing)) {
|
||||
LOG.warn("Attempted open of " + region.getEncodedName()
|
||||
+ " but already online on this server");
|
||||
builder.addOpeningState(RegionOpeningState.ALREADY_OPENED);
|
||||
continue;
|
||||
builder.addOpeningState(RegionOpeningState.ALREADY_OPENED);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
LOG.warn("The region " + region.getEncodedName() + " is online on this server" +
|
||||
" but META does not have this server - continue opening.");
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
|
||||
package org.apache.hadoop.hbase.regionserver;
|
||||
|
||||
import com.google.protobuf.ServiceException;
|
||||
import junit.framework.Assert;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.MediumTests;
|
||||
import org.apache.hadoop.hbase.exceptions.NotServingRegionException;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.exceptions.NotServingRegionException;
|
||||
import org.apache.hadoop.hbase.exceptions.RegionAlreadyInTransitionException;
|
||||
import org.apache.hadoop.hbase.executor.EventType;
|
||||
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
|
||||
|
@ -37,10 +36,13 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.apache.hadoop.hbase.zookeeper.ZKAssign;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import com.google.protobuf.ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Tests on the region server, without the master.
|
||||
|
@ -234,6 +236,24 @@ public class TestRegionServerNoMaster {
|
|||
checkRegionIsOpened();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenClosingRegion() throws Exception {
|
||||
Assert.assertTrue(getRS().getRegion(regionName).isAvailable());
|
||||
|
||||
try {
|
||||
// fake region to be closing now, need to clear state afterwards
|
||||
getRS().regionsInTransitionInRS.put(hri.getEncodedNameAsBytes(), Boolean.FALSE);
|
||||
AdminProtos.OpenRegionRequest orr = RequestConverter.buildOpenRegionRequest(hri, 0, null);
|
||||
getRS().openRegion(null, orr);
|
||||
Assert.fail("The closing region should not be opened");
|
||||
} catch (ServiceException se) {
|
||||
Assert.assertTrue("The region should be already in transition",
|
||||
se.getCause() instanceof RegionAlreadyInTransitionException);
|
||||
} finally {
|
||||
getRS().regionsInTransitionInRS.remove(hri.getEncodedNameAsBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testMultipleCloseFromMaster() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue