Skip to content

Commit

Permalink
HBASE-27405 Fix the replication hfile/log cleaner report that the rep…
Browse files Browse the repository at this point in the history
…lication table does not exist (#4811)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
2005hithlj authored and Apache9 committed Mar 18, 2023
1 parent 31c8f8c commit 26d6ba2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,10 @@ void removeLastSequenceIds(String peerId, List<String> encodedRegionNames)
* 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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -532,4 +532,13 @@ public Set<String> getAllHFileRefs() throws ReplicationException {
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public void preClean() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void setUp() throws ReplicationException {
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);
Expand Down

0 comments on commit 26d6ba2

Please sign in to comment.