HBASE-2524 Unresponsive region server, potential deadlock

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@944385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-05-14 18:51:36 +00:00
parent 4e080fcbbb
commit b1f8ce99c1
2 changed files with 45 additions and 36 deletions

View File

@ -563,6 +563,8 @@ Release 0.21.0 - Unreleased
HBASE-2537 Change ordering of maven repos listed in pom.xml to have
ibiblio first
HBASE-2540 Make QueryMatcher.MatchCode public (Clint Morgan via Stack)
HBASE-2524 Unresponsive region server, potential deadlock
(Todd Lipcon via Stack)
NEW FEATURES
HBASE-1961 HBase EC2 scripts

View File

@ -23,6 +23,7 @@ package org.apache.hadoop.hbase.regionserver;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import java.util.Arrays;
import org.apache.hadoop.hbase.HBaseTestCase;
import org.apache.hadoop.hbase.HConstants;
@ -40,6 +41,31 @@ implements HConstants {
private final byte [] col4 = Bytes.toBytes("col4");
private final byte [] col5 = Bytes.toBytes("col5");
private void runTest(int maxVersions,
TreeSet<byte[]> trackColumns,
List<byte[]> scannerColumns,
List<MatchCode> expected) {
ColumnTracker exp = new ExplicitColumnTracker(
trackColumns, maxVersions);
//Initialize result
List<MatchCode> result = new ArrayList<MatchCode>();
//"Match"
for(byte [] col : scannerColumns){
result.add(exp.checkColumn(col, 0, col.length));
}
assertEquals(expected.size(), result.size());
for(int i=0; i< expected.size(); i++){
assertEquals(expected.get(i), result.get(i));
if(PRINT){
System.out.println("Expected " +expected.get(i) + ", actual " +
result.get(i));
}
}
}
public void testGet_SingleVersion(){
if(PRINT){
@ -59,8 +85,6 @@ implements HConstants {
expected.add(MatchCode.DONE);
int maxVersions = 1;
ColumnTracker exp = new ExplicitColumnTracker(columns, maxVersions);
//Create "Scanner"
List<byte[]> scanner = new ArrayList<byte[]>();
scanner.add(col1);
@ -69,22 +93,7 @@ implements HConstants {
scanner.add(col4);
scanner.add(col5);
//Initialize result
List<MatchCode> result = new ArrayList<MatchCode>();
//"Match"
for(byte [] col : scanner){
result.add(exp.checkColumn(col, 0, col.length));
}
assertEquals(expected.size(), result.size());
for(int i=0; i< expected.size(); i++){
assertEquals(expected.get(i), result.get(i));
if(PRINT){
System.out.println("Expected " +expected.get(i) + ", actual " +
result.get(i));
}
}
runTest(maxVersions, columns, scanner, expected);
}
public void testGet_MultiVersion(){
@ -120,8 +129,6 @@ implements HConstants {
expected.add(MatchCode.DONE);
int maxVersions = 2;
ColumnTracker exp = new ExplicitColumnTracker(columns, maxVersions);
//Create "Scanner"
List<byte[]> scanner = new ArrayList<byte[]>();
scanner.add(col1);
@ -141,21 +148,7 @@ implements HConstants {
scanner.add(col5);
//Initialize result
List<MatchCode> result = new ArrayList<MatchCode>();
//"Match"
for(byte [] col : scanner){
result.add(exp.checkColumn(col, 0, col.length));
}
assertEquals(expected.size(), result.size());
for(int i=0; i< expected.size(); i++){
assertEquals(expected.get(i), result.get(i));
if(PRINT){
System.out.println("Expected " +expected.get(i) + ", actual " +
result.get(i));
}
}
runTest(maxVersions, columns, scanner, expected);
}
@ -182,5 +175,19 @@ implements HConstants {
}
}
/**
* Regression test for HBASE-2545
*/
public void testInfiniteLoop() {
TreeSet<byte[]> columns = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
columns.addAll(Arrays.asList(new byte[][] {
col2, col3, col5 }));
List<byte[]> scanner = Arrays.<byte[]>asList(
new byte[][] { col1, col4 });
List<MatchCode> expected = Arrays.<MatchCode>asList(
new MatchCode[] {
MatchCode.SKIP,
MatchCode.SKIP });
runTest(1, columns, scanner, expected);
}
}