diff --git a/CHANGES.txt b/CHANGES.txt index 839588168ef..f60986b3b36 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -120,6 +120,7 @@ Release 0.90.2 - Unreleased (Himanshu Vashishtha via garyh) HBASE-3576 MasterAddressTracker is registered to ZooKeeperWatcher twice HBASE-3561 OPTS arguments are duplicated + HBASE-3572 memstore lab can leave half inited data structs (bad!) IMPROVEMENTS HBASE-3542 MultiGet methods in Thrift diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreLAB.java b/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreLAB.java index f77355e38f1..cbb76e8be09 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreLAB.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreLAB.java @@ -154,6 +154,7 @@ public class MemStoreLAB { private byte[] data; private static final int UNINITIALIZED = -1; + private static final int OOM = -2; /** * Offset for the next allocation, or the sentinel value -1 * which implies that the chunk is still uninitialized. @@ -182,7 +183,13 @@ public class MemStoreLAB { */ public void init() { assert nextFreeOffset.get() == UNINITIALIZED; - data = new byte[size]; + try { + data = new byte[size]; + } catch (OutOfMemoryError e) { + boolean failInit = nextFreeOffset.compareAndSet(UNINITIALIZED, OOM); + assert failInit; // should be true. + throw e; + } // Mark that it's ready for use boolean initted = nextFreeOffset.compareAndSet( UNINITIALIZED, 0); @@ -207,6 +214,10 @@ public class MemStoreLAB { Thread.yield(); continue; } + if (oldOffset == OOM) { + // doh we ran out of ram. return -1 to chuck this away. + return -1; + } if (oldOffset + size > data.length) { return -1; // alloc doesn't fit