You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2022/05/07 17:45:33 UTC
[hbase] branch branch-2.5 updated: HBASE-26963 ReplicationSource#removePeer hangs if we try to remove bad peer. (#4413)
This is an automated email from the ASF dual-hosted git repository.
apurtell pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new ffbdac12ca HBASE-26963 ReplicationSource#removePeer hangs if we try to remove bad peer. (#4413)
ffbdac12ca is described below
commit ffbdac12ca5b34ad01f0b8dab380eef41ffdcc4b
Author: Rushabh Shah <sh...@gmail.com>
AuthorDate: Sat May 7 10:38:17 2022 -0700
HBASE-26963 ReplicationSource#removePeer hangs if we try to remove bad peer. (#4413)
Signed-off-by: Andrew Purtell <ap...@apache.org>
Conflicts:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
---
.../regionserver/ReplicationSource.java | 15 +++-
.../client/replication/TestBadReplicationPeer.java | 93 ++++++++++++++++++++++
2 files changed, 106 insertions(+), 2 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
index 3d1746edd8..64bba81d9e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
@@ -552,8 +552,14 @@ public class ReplicationSource implements ReplicationSourceInterface {
}
if (!this.isSourceActive()) {
- retryStartup.set(!this.abortOnError);
setSourceStartupStatus(false);
+ if (Thread.currentThread().isInterrupted()) {
+ // If source is not running and thread is interrupted this means someone has tried to
+ // remove this peer.
+ return;
+ }
+
+ retryStartup.set(!this.abortOnError);
throw new IllegalStateException("Source should be active.");
}
@@ -576,8 +582,13 @@ public class ReplicationSource implements ReplicationSourceInterface {
}
if (!this.isSourceActive()) {
- retryStartup.set(!this.abortOnError);
setSourceStartupStatus(false);
+ if (Thread.currentThread().isInterrupted()) {
+ // If source is not running and thread is interrupted this means someone has tried to
+ // remove this peer.
+ return;
+ }
+ retryStartup.set(!this.abortOnError);
throw new IllegalStateException("Source should be active.");
}
LOG.info("{} queueId={} (queues={}) is replicating from cluster={} to cluster={}", logPeerId(),
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestBadReplicationPeer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestBadReplicationPeer.java
new file mode 100644
index 0000000000..f3e0af5432
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestBadReplicationPeer.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.client.replication;
+
+import java.io.IOException;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
+import org.apache.hadoop.hbase.replication.ReplicationPeerConfigBuilder;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Category({ MediumTests.class, ClientTests.class })
+public class TestBadReplicationPeer {
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestBadReplicationPeer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestBadReplicationPeer.class);
+ private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ private static Configuration conf;
+
+ @Rule
+ public TestName name = new TestName();
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
+ TEST_UTIL.getConfiguration().setBoolean("replication.source.regionserver.abort", false);
+ TEST_UTIL.startMiniCluster();
+ conf = TEST_UTIL.getConfiguration();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ /*
+ * Add dummy peer and make sure that we are able to remove that peer.
+ */
+ @Test
+ public void testRemovePeerSucceeds() throws IOException {
+ String peerId = "dummypeer_1";
+ try (Connection connection = ConnectionFactory.createConnection(conf);
+ Admin admin = connection.getAdmin()) {
+ ReplicationPeerConfigBuilder rpcBuilder = ReplicationPeerConfig.newBuilder();
+ String quorum = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper().getQuorum();
+ rpcBuilder.setClusterKey(quorum + ":/1");
+ ReplicationPeerConfig rpc = rpcBuilder.build();
+ admin.addReplicationPeer(peerId, rpc);
+ LOG.info("Added replication peer with peer id: {}", peerId);
+ } finally {
+ LOG.info("Removing replication peer with peer id: {}", peerId);
+ cleanPeer(peerId);
+ }
+ }
+
+ private static void cleanPeer(String peerId) throws IOException {
+ try (Connection connection = ConnectionFactory.createConnection(conf);
+ Admin admin = connection.getAdmin()) {
+ admin.removeReplicationPeer(peerId);
+ }
+ }
+}