HBASE-27405 Fix the replication hfile/log cleaner report that the replication table does not exist (#4811)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
LiangJun He 2022-10-12 14:40:05 +08:00 committed by Duo Zhang
parent c01c8e45b4
commit 5f95a914b6
4 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

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

View File

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

View File

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