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:
BukrosSzabolcs 2020-07-14 18:24:55 +02:00 committed by GitHub
parent 70cfe2525e
commit 3e709c6f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 6 deletions

View File

@ -56,10 +56,6 @@ class MasterMetaBootstrap {
throws IOException, InterruptedException, KeeperException {
int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM,
HConstants.DEFAULT_META_REPLICA_NUM);
if (numReplicas <= 1) {
// No replicaas to assign. Return.
return;
}
final AssignmentManager assignmentManager = master.getAssignmentManager();
if (!assignmentManager.isMetaLoaded()) {
throw new IllegalStateException("hbase:meta must be initialized first before we can " +

View File

@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.YouAreDeadException;
import org.apache.hadoop.hbase.client.AsyncClusterConnection;
import org.apache.hadoop.hbase.client.AsyncRegionServerAdmin;
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.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.procedure2.Procedure;
@ -715,7 +716,10 @@ public class ServerManager {
return;
}
} catch (IOException ioe) {
if (ioe instanceof NotServingRegionException) {
if (ioe instanceof NotServingRegionException ||
(ioe instanceof RemoteWithExtrasException &&
((RemoteWithExtrasException)ioe).unwrapRemoteException()
instanceof NotServingRegionException)) {
// no need to retry again
return;
}

View File

@ -20,15 +20,17 @@ package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
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.MiscTests;
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.ZKWatcher;
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
public void testAccessingUnknownTables() throws Exception {
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());