HBASE-14897 TestTableLockManager.testReapAllTableLocks is flakey

(cherry picked from commit 47082579a8)
Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
chenheng 2015-12-01 10:31:00 +08:00 committed by Sean Busbey
parent 99306bba77
commit 7990546efe
1 changed files with 28 additions and 4 deletions

View File

@ -42,7 +42,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.InterProcessLock;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.ScheduledChore;
import org.apache.hadoop.hbase.ServerName;
@ -55,6 +55,7 @@ import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.exceptions.LockTimeoutException;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.LoadTestTool;
import org.apache.hadoop.hbase.util.StoppableImplementation;
@ -130,7 +131,7 @@ public class TestTableLockManager {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
master.getMasterCoprocessorHost().load(TestAlterAndDisableMasterObserver.class,
0, TEST_UTIL.getConfiguration());
0, TEST_UTIL.getConfiguration());
ExecutorService executor = Executors.newFixedThreadPool(2);
Future<Object> alterTableFuture = executor.submit(new Callable<Object>() {
@ -234,6 +235,23 @@ public class TestTableLockManager {
}
public class TableLockCounter implements InterProcessLock.MetadataHandler {
private int lockCount = 0;
@Override
public void handleMetadata(byte[] metadata) {
lockCount++;
}
public void reset() {
lockCount = 0;
}
public int getLockCount() {
return lockCount;
}
}
@Test(timeout = 600000)
public void testReapAllTableLocks() throws Exception {
@ -258,7 +276,7 @@ public class TestTableLockManager {
public Void call() throws Exception {
writeLocksAttempted.countDown();
lockManager.writeLock(TableName.valueOf(table),
"testReapAllTableLocks").acquire();
"testReapAllTableLocks").acquire();
writeLocksObtained.countDown();
return null;
}
@ -269,9 +287,15 @@ public class TestTableLockManager {
writeLocksObtained.await();
writeLocksAttempted.await();
TableLockCounter counter = new TableLockCounter();
do {
counter.reset();
lockManager.visitAllLocks(counter);
Thread.sleep(10);
} while (counter.getLockCount() != 10);
//now reap all table locks
lockManager.reapWriteLocks();
TEST_UTIL.getConfiguration().setInt(TableLockManager.TABLE_WRITE_LOCK_TIMEOUT_MS, 0);
TableLockManager zeroTimeoutLockManager = TableLockManager.createTableLockManager(
TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName);