HBASE-6900 RegionScanner.reseek() creates NPE when a flush or compaction happens before the reseek.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1394377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6f1af4dba4
commit
30c7e958ee
|
@ -561,8 +561,10 @@ public class StoreScanner extends NonLazyKeyValueScanner
|
|||
|
||||
@Override
|
||||
public synchronized boolean reseek(KeyValue kv) throws IOException {
|
||||
//Heap cannot be null, because this is only called from next() which
|
||||
//guarantees that heap will never be null before this call.
|
||||
//Heap will not be null, if this is called from next() which.
|
||||
//If called from RegionScanner.reseek(...) make sure the scanner
|
||||
//stack is reset if needed.
|
||||
checkReseek();
|
||||
if (explicitColumnQuery && lazySeekEnabledGlobally) {
|
||||
return heap.requestSeek(kv, true, useRowColBloom);
|
||||
} else {
|
||||
|
|
|
@ -93,6 +93,7 @@ import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
|
|||
import org.apache.hadoop.hbase.util.Pair;
|
||||
import org.apache.hadoop.hbase.util.PairOfSameType;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.mockito.Mockito;
|
||||
|
@ -205,6 +206,40 @@ public class TestHRegion extends HBaseTestCase {
|
|||
System.out.println(results);
|
||||
assertEquals(0, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToShowNPEOnRegionScannerReseek() throws Exception{
|
||||
String method = "testToShowNPEOnRegionScannerReseek";
|
||||
byte[] tableName = Bytes.toBytes(method);
|
||||
byte[] family = Bytes.toBytes("family");
|
||||
Configuration conf = HBaseConfiguration.create();
|
||||
this.region = initHRegion(tableName, method, conf, family);
|
||||
|
||||
Put put = new Put(Bytes.toBytes("r1"));
|
||||
put.add(family, Bytes.toBytes("q1"), Bytes.toBytes("v1"));
|
||||
region.put(put);
|
||||
put = new Put(Bytes.toBytes("r2"));
|
||||
put.add(family, Bytes.toBytes("q1"), Bytes.toBytes("v1"));
|
||||
region.put(put);
|
||||
region.flushcache();
|
||||
|
||||
|
||||
Scan scan = new Scan();
|
||||
scan.setMaxVersions(3);
|
||||
// open the first scanner
|
||||
RegionScanner scanner1 = region.getScanner(scan);
|
||||
|
||||
System.out.println("Smallest read point:" + region.getSmallestReadPoint());
|
||||
|
||||
region.compactStores(true);
|
||||
|
||||
scanner1.reseek(Bytes.toBytes("r2"));
|
||||
List<KeyValue> results = new ArrayList<KeyValue>();
|
||||
scanner1.next(results);
|
||||
KeyValue keyValue = results.get(0);
|
||||
Assert.assertTrue(Bytes.compareTo(keyValue.getRow(), Bytes.toBytes("r2")) == 0);
|
||||
scanner1.close();
|
||||
}
|
||||
|
||||
public void testSkipRecoveredEditsReplay() throws Exception {
|
||||
String method = "testSkipRecoveredEditsReplay";
|
||||
|
|
Loading…
Reference in New Issue