Bug: Snapshot based mapreduce jobs fails with NPE while trying to close mslab within mapper
Status: Resolved | Priority: Major | Resolution: Fixed
Created: 19/Jul/24 06:45

{code:java}
2024-07-11 10:20:38,800 WARN  [main] client.ClientSideRegionScanner - Exception while closing region
java.io.IOException: java.lang.NullPointerException
        at org.apache.hadoop.hbase.regionserver.HRegion.doClose(HRegion.java:1808)
        at org.apache.hadoop.hbase.regionserver.HRegion.close(HRegion.java:1557)
        at org.apache.hadoop.hbase.client.ClientSideRegionScanner.close(ClientSideRegionScanner.java:133)
        at org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormatImpl$RecordReader.close(TableSnapshotInputFormatImpl.java:310)
        at org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormat$TableSnapshotRegionRecordReader.close(TableSnapshotInputFormat.java:184)
        at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.close(MapTask.java:536)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:804)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:348)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:178)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:172)
Caused by: java.lang.NullPointerException
        at org.apache.hadoop.hbase.regionserver.MemStoreLABImpl.recycleChunks(MemStoreLABImpl.java:296)
        at org.apache.hadoop.hbase.regionserver.MemStoreLABImpl.lambda$new$0(MemStoreLABImpl.java:109)
        at org.apache.hadoop.hbase.nio.RefCnt.deallocate(RefCnt.java:95)
        at org.apache.hbase.thirdparty.io.netty.util.AbstractReferenceCounted.handleRelease(AbstractReferenceCounted.java:86)
        at org.apache.hbase.thirdparty.io.netty.util.AbstractReferenceCounted.release(AbstractReferenceCounted.java:76)
        at org.apache.hadoop.hbase.nio.RefCnt.release(RefCnt.java:84)
        at org.apache.hadoop.hbase.regionserver.MemStoreLABImpl.close(MemStoreLABImpl.java:269)
        at org.apache.hadoop.hbase.regionserver.Segment.close(Segment.java:143)
        at org.apache.hadoop.hbase.regionserver.AbstractMemStore.close(AbstractMemStore.java:381)
        at org.apache.hadoop.hbase.regionserver.HStore.closeWithoutLock(HStore.java:723)
        at org.apache.hadoop.hbase.regionserver.HStore.close(HStore.java:795)
        at org.apache.hadoop.hbase.regionserver.HRegion$2.call(HRegion.java:1786)
        at org.apache.hadoop.hbase.regionserver.HRegion$2.call(HRegion.java:1783)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750) {code}
This happens because the ChunkCreator is only initialized as part of HRegionServer [here.|https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java#L410-L431]

HRegion created on top of snapshot files within mapper wouldn't have ChunkCreator initialized causing NPE while trying to close the memstore

This is seen after https://issues.apache.org/jira/browse/HBASE-28401

There are 2 possible solutions here : 
1. Initialize ChunkCreator as while trying to create HRegion within snapashot based mapper
2. Disable the mslab altogether (via hbase.hregion.memstore.mslab.enabled set to false) within snapashot based mapper