ihbase icon indicating copy to clipboard operation
ihbase copied to clipboard

NPE in IdxRegion.IdxRegionScanner/KeyProvider with HBase 0.20.5

Open jbaldassari opened this issue 15 years ago • 3 comments

Between HBase-0.20.4 and HBase-0.20.5 the method HRegion.RegionScanner.initHeap() was removed, and the code that was previously in that method was moved into the HRegion.RegionScanner constructor. As a result of this change, IdxRegion.IdxRegionScanner fails to initialize properly.

The problem is that lines 318-321 in IdxRegion check if storeHeap == null, and the KeyProvider instance is only initialized if that condition is true. But storeHeap is never null because it is initialized in the HRegion.RegionScanner constructor, so the KeyProvider never gets initialized, and any methods called on it throw NPE because memstoreHeap is null.

The fix is simple, and I have a patch that I'll attach shortly.

jbaldassari avatar Jul 07 '10 00:07 jbaldassari

Hmm, not sure how to attach a file here (I guess I'm supposed to fork the project or something?), but the patch is so trivial that I'll just paste it here, and hopefully it'll show up ok:

/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java index 8ce32ab..8e1eade 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java @@ -309,16 +309,13 @@ public class IdxRegion extends HRegion {

         numberOfOngoingIndexedScans.incrementAndGet();
         keyProvider = new KeyProvider(idxSearchContext, matchedExpression, scan);
  •        keyProvider.init();
     }
    
    
     @Override
     public boolean next(List<KeyValue> outResults) throws IOException {
         ReadWriteConsistencyControl.resetThreadReadPoint(rwcc);
    
  •        if (storeHeap == null) {
    
  •            keyProvider.init();
    
  •            initHeap();
    
  •        }
         //DebugPrint.println("IdxScanner.next");
         // Seek to the next key value
         seekNext();
    

jbaldassari avatar Jul 07 '10 00:07 jbaldassari

/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java
index 8ce32ab..8e1eade 100644
--- a/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java
+++ b/src/main/java/org/apache/hadoop/hbase/regionserver/IdxRegion.java
@@ -309,16 +309,13 @@ public class IdxRegion extends HRegion {
 
             numberOfOngoingIndexedScans.incrementAndGet();
             keyProvider = new KeyProvider(idxSearchContext, matchedExpression, scan);
+            keyProvider.init();
         }
 
 
         @Override
         public boolean next(List outResults) throws IOException {
             ReadWriteConsistencyControl.resetThreadReadPoint(rwcc);
-            if (storeHeap == null) {
-                keyProvider.init();
-                initHeap();
-            }
             //DebugPrint.println("IdxScanner.next");
             // Seek to the next key value
             seekNext();

jbaldassari avatar Jul 07 '10 00:07 jbaldassari

OK, that looks better. Let me know if there is a better way to submit the patch.

jbaldassari avatar Jul 07 '10 00:07 jbaldassari