You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2018/09/03 15:09:03 UTC

carbondata git commit: [CARBONDATA-2901] Fixed JVM crash in Load scenario when unsafe memory allocation is failed.

Repository: carbondata
Updated Branches:
  refs/heads/master d980d4cd8 -> 257672790


[CARBONDATA-2901] Fixed JVM crash in Load scenario when unsafe memory allocation is failed.

When allocation failed, set row page reference to null.
So, that next thread will not do any operation.

This closes #2675


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

Branch: refs/heads/master
Commit: 2576727908645c66965598ea84c5948d7a8192d6
Parents: d980d4c
Author: ajantha-bhat <aj...@gmail.com>
Authored: Thu Aug 30 19:48:34 2018 +0530
Committer: Jacky Li <ja...@qq.com>
Committed: Mon Sep 3 23:07:59 2018 +0800

----------------------------------------------------------------------
 .../loading/sort/unsafe/UnsafeSortDataRows.java | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/25767279/processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/UnsafeSortDataRows.java
----------------------------------------------------------------------
diff --git a/processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/UnsafeSortDataRows.java b/processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/UnsafeSortDataRows.java
index 76532f0..f4437fb 100644
--- a/processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/UnsafeSortDataRows.java
+++ b/processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/UnsafeSortDataRows.java
@@ -188,13 +188,24 @@ public class UnsafeSortDataRows {
   }
 
   private void addBatch(Object[][] rowBatch, int size) throws CarbonSortKeyAndGroupByException {
+    if (rowPage == null) {
+      return;
+    }
     for (int i = 0; i < size; i++) {
       if (rowPage.canAdd()) {
         bytesAdded += rowPage.addRow(rowBatch[i], rowBuffer.get());
       } else {
         try {
           handlePreviousPage();
-          rowPage = createUnsafeRowPage();
+          try {
+            rowPage = createUnsafeRowPage();
+          } catch (Exception ex) {
+            // row page has freed in handlePreviousPage(), so other iterator may try to access it.
+            rowPage = null;
+            LOGGER.error(
+                "exception occurred while trying to acquire a semaphore lock: " + ex.getMessage());
+            throw new CarbonSortKeyAndGroupByException(ex);
+          }
           bytesAdded += rowPage.addRow(rowBatch[i], rowBuffer.get());
         } catch (Exception e) {
           LOGGER.error(
@@ -210,6 +221,9 @@ public class UnsafeSortDataRows {
    * This method will be used to add new row
    */
   public void addRow(Object[] row) throws CarbonSortKeyAndGroupByException {
+    if (rowPage == null) {
+      return;
+    }
     // if record holder list size is equal to sort buffer size then it will
     // sort the list and then write current list data to file
     if (rowPage.canAdd()) {
@@ -217,7 +231,14 @@ public class UnsafeSortDataRows {
     } else {
       try {
         handlePreviousPage();
-        rowPage = createUnsafeRowPage();
+        try {
+          rowPage = createUnsafeRowPage();
+        } catch (Exception ex) {
+          rowPage = null;
+          LOGGER.error(
+              "exception occurred while trying to acquire a semaphore lock: " + ex.getMessage());
+          throw new CarbonSortKeyAndGroupByException(ex);
+        }
         rowPage.addRow(row, rowBuffer.get());
       } catch (Exception e) {
         LOGGER.error(