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 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);