drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [2/7] drill git commit: DRILL-3110: Coerce Java's Direct OutOfMemoryErrors to look like reservation failures to follow existing Drill behavior paths.
Date Sat, 16 May 2015 01:39:06 GMT
DRILL-3110: Coerce Java's Direct OutOfMemoryErrors to look like reservation failures to follow
existing Drill behavior paths.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/30f58920
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/30f58920
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/30f58920

Branch: refs/heads/1.0.0
Commit: 30f589204aeae2568a58efe595b5e516f4cddfed
Parents: dd35b27
Author: Jacques Nadeau <jacques@apache.org>
Authored: Fri May 15 16:50:01 2015 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Fri May 15 17:37:28 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/memory/Accountor.java |  4 +++
 .../drill/exec/memory/TopLevelAllocator.java    | 35 +++++++++++++++-----
 2 files changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/30f58920/exec/java-exec/src/main/java/org/apache/drill/exec/memory/Accountor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/Accountor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/Accountor.java
index eb932ad..ad6a787 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/Accountor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/Accountor.java
@@ -197,6 +197,10 @@ public class Accountor {
     }
   }
 
+  void release(long size) {
+    remainder.returnAllocation(size);
+  }
+
   public void release(DrillBuf buf, long size) {
     remainder.returnAllocation(size);
     if (ENABLE_ACCOUNTING) {

http://git-wip-us.apache.org/repos/asf/drill/blob/30f58920/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
index f6a37e7..e2d5b18 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
@@ -95,10 +95,20 @@ public class TopLevelAllocator implements BufferAllocator {
     if(!acct.reserve(min)) {
       return null;
     }
-    UnsafeDirectLittleEndian buffer = innerAllocator.directBuffer(min, max);
-    DrillBuf wrapped = new DrillBuf(this, acct, buffer);
-    acct.reserved(min, wrapped);
-    return wrapped;
+
+    try {
+      UnsafeDirectLittleEndian buffer = innerAllocator.directBuffer(min, max);
+      DrillBuf wrapped = new DrillBuf(this, acct, buffer);
+      acct.reserved(min, wrapped);
+      return wrapped;
+    } catch (OutOfMemoryError e) {
+      if ("Direct buffer memory".equals(e.getMessage())) {
+        acct.release(min);
+        return null;
+      } else {
+        throw e;
+      }
+    }
   }
 
   @Override
@@ -244,10 +254,19 @@ public class TopLevelAllocator implements BufferAllocator {
         return null;
       }
 
-      UnsafeDirectLittleEndian buffer = innerAllocator.directBuffer(size, max);
-      DrillBuf wrapped = new DrillBuf(this, childAcct, buffer);
-      childAcct.reserved(buffer.capacity(), wrapped);
-      return wrapped;
+      try {
+        UnsafeDirectLittleEndian buffer = innerAllocator.directBuffer(size, max);
+        DrillBuf wrapped = new DrillBuf(this, childAcct, buffer);
+        childAcct.reserved(buffer.capacity(), wrapped);
+        return wrapped;
+      } catch (OutOfMemoryError e) {
+        if ("Direct buffer memory".equals(e.getMessage())) {
+          childAcct.release(size);
+          return null;
+        } else {
+          throw e;
+        }
+      }
     }
 
     public DrillBuf buffer(int size) {


Mime
View raw message