Skip to content

Commit 5f95a91

Browse files
2005hithljApache9
authored andcommitted
HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist (#4811)
Signed-off-by: Duo Zhang <[email protected]>
1 parent c01c8e4 commit 5f95a91

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueueStorage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,10 @@ void removeLastSequenceIds(String peerId, List<String> encodedRegionNames)
178178
* created hfile references during the call may not be included.
179179
*/
180180
Set<String> getAllHFileRefs() throws ReplicationException;
181+
182+
/**
183+
* Whether the replication queue table exists.
184+
* @return Whether the replication queue table exists
185+
*/
186+
boolean hasData() throws ReplicationException;
181187
}

hbase-replication/src/main/java/org/apache/hadoop/hbase/replication/TableReplicationQueueStorage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,4 +532,13 @@ public Set<String> getAllHFileRefs() throws ReplicationException {
532532
throw new ReplicationException("failed to getAllHFileRefs", e);
533533
}
534534
}
535+
536+
@Override
537+
public boolean hasData() throws ReplicationException {
538+
try {
539+
return conn.getAdmin().getDescriptor(tableName) != null;
540+
} catch (IOException e) {
541+
throw new ReplicationException("failed to get replication queue table", e);
542+
}
543+
}
535544
}

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ public void preClean() {
7676
if (this.getConf() == null) {
7777
return;
7878
}
79+
try {
80+
if (!rpm.getQueueStorage().hasData()) {
81+
return;
82+
}
83+
} catch (ReplicationException e) {
84+
LOG.error("Error occurred while executing queueStorage.hasData()", e);
85+
return;
86+
}
7987
canFilter = rpm.getReplicationLogCleanerBarrier().start();
8088
if (canFilter) {
8189
notFullyDeadServers = getNotFullyDeadServers.get();

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/master/TestReplicationLogCleaner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void setUp() throws ReplicationException {
8686
when(rpm.listPeers(null)).thenReturn(new ArrayList<>());
8787
ReplicationQueueStorage rqs = mock(ReplicationQueueStorage.class);
8888
when(rpm.getQueueStorage()).thenReturn(rqs);
89+
when(rpm.getQueueStorage().hasData()).thenReturn(true);
8990
when(rqs.listAllQueues()).thenReturn(new ArrayList<>());
9091
ServerManager sm = mock(ServerManager.class);
9192
when(services.getServerManager()).thenReturn(sm);

0 commit comments

Comments
 (0)