HBASE-14621 ReplicationLogCleaner stuck on RS crash.
Signed-off-by: Elliott Clark <eclark@apache.org>
This commit is contained in:
parent
e874a31d75
commit
6774f223a4
|
@ -95,8 +95,8 @@ public class ReplicationLogCleaner extends BaseLogCleanerDelegate implements Abo
|
||||||
* not be included.
|
* not be included.
|
||||||
*/
|
*/
|
||||||
private Set<String> loadWALsFromQueues() throws KeeperException {
|
private Set<String> loadWALsFromQueues() throws KeeperException {
|
||||||
int v0 = replicationQueues.getQueuesZNodeCversion();
|
|
||||||
for (int retry = 0; ; retry++) {
|
for (int retry = 0; ; retry++) {
|
||||||
|
int v0 = replicationQueues.getQueuesZNodeCversion();
|
||||||
List<String> rss = replicationQueues.getListOfReplicators();
|
List<String> rss = replicationQueues.getListOfReplicators();
|
||||||
if (rss == null) {
|
if (rss == null) {
|
||||||
LOG.debug("Didn't find any region server that replicates, won't prevent any deletions.");
|
LOG.debug("Didn't find any region server that replicates, won't prevent any deletions.");
|
||||||
|
|
|
@ -20,7 +20,9 @@ package org.apache.hadoop.hbase.master.cleaner;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileStatus;
|
import org.apache.hadoop.fs.FileStatus;
|
||||||
|
@ -36,6 +38,8 @@ import org.apache.hadoop.hbase.Waiter;
|
||||||
import org.apache.hadoop.hbase.client.ClusterConnection;
|
import org.apache.hadoop.hbase.client.ClusterConnection;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationFactory;
|
import org.apache.hadoop.hbase.replication.ReplicationFactory;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationQueues;
|
import org.apache.hadoop.hbase.replication.ReplicationQueues;
|
||||||
|
import org.apache.hadoop.hbase.replication.ReplicationQueuesClient;
|
||||||
|
import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner;
|
||||||
import org.apache.hadoop.hbase.replication.regionserver.Replication;
|
import org.apache.hadoop.hbase.replication.regionserver.Replication;
|
||||||
import org.apache.hadoop.hbase.testclassification.MasterTests;
|
import org.apache.hadoop.hbase.testclassification.MasterTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
|
@ -45,6 +49,7 @@ import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
@Category({MasterTests.class, MediumTests.class})
|
@Category({MasterTests.class, MediumTests.class})
|
||||||
public class TestLogsCleaner {
|
public class TestLogsCleaner {
|
||||||
|
@ -126,6 +131,7 @@ public class TestLogsCleaner {
|
||||||
assertEquals(34, fs.listStatus(oldLogDir).length);
|
assertEquals(34, fs.listStatus(oldLogDir).length);
|
||||||
|
|
||||||
LogCleaner cleaner = new LogCleaner(1000, server, conf, fs, oldLogDir);
|
LogCleaner cleaner = new LogCleaner(1000, server, conf, fs, oldLogDir);
|
||||||
|
|
||||||
cleaner.chore();
|
cleaner.chore();
|
||||||
|
|
||||||
// We end up with the current log file, a newer one and the 3 old log
|
// We end up with the current log file, a newer one and the 3 old log
|
||||||
|
@ -142,6 +148,24 @@ public class TestLogsCleaner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout=5000)
|
||||||
|
public void testZnodeCversionChange() throws Exception {
|
||||||
|
Configuration conf = TEST_UTIL.getConfiguration();
|
||||||
|
ReplicationLogCleaner cleaner = new ReplicationLogCleaner();
|
||||||
|
cleaner.setConf(conf);
|
||||||
|
|
||||||
|
ReplicationQueuesClient rqcMock = Mockito.mock(ReplicationQueuesClient.class);
|
||||||
|
Mockito.when(rqcMock.getQueuesZNodeCversion()).thenReturn(1, 2, 3, 4);
|
||||||
|
|
||||||
|
Field rqc = ReplicationLogCleaner.class.getDeclaredField("replicationQueues");
|
||||||
|
rqc.setAccessible(true);
|
||||||
|
|
||||||
|
rqc.set(cleaner, rqcMock);
|
||||||
|
|
||||||
|
// This should return eventually when cversion stabilizes
|
||||||
|
cleaner.getDeletableFiles(new LinkedList<FileStatus>());
|
||||||
|
}
|
||||||
|
|
||||||
static class DummyServer implements Server {
|
static class DummyServer implements Server {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue