You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/03/18 13:57:29 UTC

[hbase] 06/11: HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist (#4811)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch HBASE-27109/table_based_rqs
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 26d6ba2d0ad5430ff52f6481ac13cecbf1515f1e
Author: LiangJun He <20...@163.com>
AuthorDate: Wed Oct 12 14:40:05 2022 +0800

    HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist (#4811)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../apache/hadoop/hbase/replication/ReplicationQueueStorage.java | 6 ++++++
 .../hadoop/hbase/replication/TableReplicationQueueStorage.java   | 9 +++++++++
 .../hadoop/hbase/replication/master/ReplicationLogCleaner.java   | 8 ++++++++
 .../hbase/replication/master/TestReplicationLogCleaner.java      | 1 +
 4 files changed, 24 insertions(+)

diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueueStorage.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueueStorage.java
index c4204f0e8c4..6f6aee38cc8 100644
--- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueueStorage.java
+++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueueStorage.java
@@ -178,4 +178,10 @@ public interface ReplicationQueueStorage {
    * created hfile references during the call may not be included.
    */
   Set<String> getAllHFileRefs() throws ReplicationException;
+
+  /**
+   * Whether the replication queue table exists.
+   * @return Whether the replication queue table exists
+   */
+  boolean hasData() throws ReplicationException;
 }
diff --git a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java
index 0c9553f4fd8..392a3692d66 100644
--- a/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java
+++ b/hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java
@@ -532,4 +532,13 @@ public class TableReplicationQueueStorage implements ReplicationQueueStorage {
       throw new ReplicationException("failed to getAllHFileRefs", e);
     }
   }
+
+  @Override
+  public boolean hasData() throws ReplicationException {
+    try {
+      return conn.getAdmin().getDescriptor(tableName) != null;
+    } catch (IOException e) {
+      throw new ReplicationException("failed to get replication queue table", e);
+    }
+  }
 }
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
index f1fd8f8d6b3..3ab52da6158 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
@@ -76,6 +76,14 @@ public class ReplicationLogCleaner extends BaseLogCleanerDelegate {
     if (this.getConf() == null) {
       return;
     }
+    try {
+      if (!rpm.getQueueStorage().hasData()) {
+        return;
+      }
+    } catch (ReplicationException e) {
+      LOG.error("Error occurred while executing queueStorage.hasData()", e);
+      return;
+    }
     canFilter = rpm.getReplicationLogCleanerBarrier().start();
     if (canFilter) {
       notFullyDeadServers = getNotFullyDeadServers.get();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
index 7a227fb0603..7edadae03b1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java
@@ -86,6 +86,7 @@ public class TestReplicationLogCleaner {
     when(rpm.listPeers(null)).thenReturn(new ArrayList<>());
     ReplicationQueueStorage rqs = mock(ReplicationQueueStorage.class);
     when(rpm.getQueueStorage()).thenReturn(rqs);
+    when(rpm.getQueueStorage().hasData()).thenReturn(true);
     when(rqs.listAllQueues()).thenReturn(new ArrayList<>());
     ServerManager sm = mock(ServerManager.class);
     when(services.getServerManager()).thenReturn(sm);