HBASE-24720: Meta replicas not cleaned when disabled (#2057)
- make sure to always clean up excess meta replicas not just when their number get decreased - make sure NotServingRegionException is handled properly even when wrapped - add test Signed-off-by: Peter Somogyi <psomogyi@apache.org>
This commit is contained in:
parent
70cfe2525e
commit
3e709c6f53
|
@ -56,10 +56,6 @@ class MasterMetaBootstrap {
|
||||||
throws IOException, InterruptedException, KeeperException {
|
throws IOException, InterruptedException, KeeperException {
|
||||||
int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM,
|
int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM,
|
||||||
HConstants.DEFAULT_META_REPLICA_NUM);
|
HConstants.DEFAULT_META_REPLICA_NUM);
|
||||||
if (numReplicas <= 1) {
|
|
||||||
// No replicaas to assign. Return.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final AssignmentManager assignmentManager = master.getAssignmentManager();
|
final AssignmentManager assignmentManager = master.getAssignmentManager();
|
||||||
if (!assignmentManager.isMetaLoaded()) {
|
if (!assignmentManager.isMetaLoaded()) {
|
||||||
throw new IllegalStateException("hbase:meta must be initialized first before we can " +
|
throw new IllegalStateException("hbase:meta must be initialized first before we can " +
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.YouAreDeadException;
|
||||||
import org.apache.hadoop.hbase.client.AsyncClusterConnection;
|
import org.apache.hadoop.hbase.client.AsyncClusterConnection;
|
||||||
import org.apache.hadoop.hbase.client.AsyncRegionServerAdmin;
|
import org.apache.hadoop.hbase.client.AsyncRegionServerAdmin;
|
||||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.ipc.RemoteWithExtrasException;
|
||||||
import org.apache.hadoop.hbase.master.assignment.RegionStates;
|
import org.apache.hadoop.hbase.master.assignment.RegionStates;
|
||||||
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
|
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
|
||||||
import org.apache.hadoop.hbase.procedure2.Procedure;
|
import org.apache.hadoop.hbase.procedure2.Procedure;
|
||||||
|
@ -715,7 +716,10 @@ public class ServerManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (ioe instanceof NotServingRegionException) {
|
if (ioe instanceof NotServingRegionException ||
|
||||||
|
(ioe instanceof RemoteWithExtrasException &&
|
||||||
|
((RemoteWithExtrasException)ioe).unwrapRemoteException()
|
||||||
|
instanceof NotServingRegionException)) {
|
||||||
// no need to retry again
|
// no need to retry again
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,17 @@ package org.apache.hadoop.hbase.client;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.TableNotFoundException;
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.MiscTests;
|
import org.apache.hadoop.hbase.testclassification.MiscTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
|
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
|
||||||
|
@ -80,6 +82,27 @@ public class TestMetaWithReplicasBasic extends MetaWithReplicasTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReplicaCleanup() throws Exception {
|
||||||
|
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
|
||||||
|
List<String> metaReplicaZnodes = zkw.getMetaReplicaNodes();
|
||||||
|
assertEquals(3, metaReplicaZnodes.size());
|
||||||
|
|
||||||
|
final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
|
||||||
|
master.stop("Restarting");
|
||||||
|
TEST_UTIL.waitFor(30000, () -> master.isStopped());
|
||||||
|
TEST_UTIL.getMiniHBaseCluster().getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 1);
|
||||||
|
|
||||||
|
JVMClusterUtil.MasterThread newMasterThread = TEST_UTIL.getMiniHBaseCluster().startMaster();
|
||||||
|
final HMaster newMaster = newMasterThread.getMaster();
|
||||||
|
|
||||||
|
//wait until new master finished meta replica assignment logic
|
||||||
|
TEST_UTIL.waitFor(30000, () -> newMaster.getMasterQuotaManager() != null);
|
||||||
|
zkw = TEST_UTIL.getZooKeeperWatcher();
|
||||||
|
metaReplicaZnodes = zkw.getMetaReplicaNodes();
|
||||||
|
assertEquals(1, metaReplicaZnodes.size());
|
||||||
|
|
||||||
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testAccessingUnknownTables() throws Exception {
|
public void testAccessingUnknownTables() throws Exception {
|
||||||
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
|
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
|
||||||
|
|
Loading…
Reference in New Issue