You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2016/06/30 17:42:19 UTC

[32/50] [abbrv] incubator-carbondata git commit: [Bug] Handling failing scenarios & providing proper logs for delete queries (#769)

[Bug] Handling failing scenarios & providing proper logs for delete queries (#769)



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

Branch: refs/heads/master
Commit: 6701eeefcdf7f8f16d4cea1ba01588c63780c5b9
Parents: 3718dc2
Author: Manu <ma...@gmail.com>
Authored: Tue Jun 28 04:59:20 2016 +0530
Committer: Venkata Ramana G <g....@gmail.com>
Committed: Tue Jun 28 04:59:20 2016 +0530

----------------------------------------------------------------------
 .../execution/command/carbonTableSchema.scala   | 32 +++++-----
 .../lcm/status/SegmentStatusManager.java        | 65 +++++++++-----------
 2 files changed, 43 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6701eeef/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala b/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
index c97a2fe..ffc7e60 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
@@ -1168,6 +1168,7 @@ private[sql] case class AlterTable(
 
 /**
  * Command for the compaction in alter table command
+ *
  * @param alterTableModel
  */
 private[sql] case class AlterTableCompaction(alterTableModel: AlterTableModel) extends
@@ -1337,25 +1338,15 @@ private[sql] case class DeleteLoadsById(
 
     val invalidLoadIds = segmentStatusManager.updateDeletionStatus(loadids.asJava, path).asScala
 
-    if (invalidLoadIds.nonEmpty) {
-      if (invalidLoadIds.length == loadids.length) {
-        LOGGER.audit(
-          "Delete load by Id is failed. Failed to delete the following load(s). LoadSeqId-" +
-          invalidLoadIds)
-        sys.error("Load deletion is failed. Failed to delete the following load(s). LoadSeqId-" +
-                  invalidLoadIds)
-      }
-      else {
-        LOGGER.audit(
-          "Delete load by Id is failed. Failed to delete the following load(s). LoadSeqId-" +
-          invalidLoadIds)
-        sys.error(
-          "Load deletion is partial success. Failed to delete the following load(s). LoadSeqId-" +
-          invalidLoadIds)
-      }
+    if (invalidLoadIds.isEmpty) {
+
+      LOGGER.audit("Delete load by Id is successfull.")
+    }
+    else {
+      sys.error("Delete load by Id is failed. No matching load id found. SegmentSeqId(s) - "
+                + invalidLoadIds)
     }
 
-    LOGGER.audit("Delete load by Id is successfull.")
     Seq.empty
 
   }
@@ -1416,7 +1407,12 @@ private[sql] case class DeleteLoadsByLoadDate(
 
     var invalidLoadTimestamps = segmentStatusManager
       .updateDeletionStatus(loadDate, path, timeObj.asInstanceOf[java.lang.Long]).asScala
-    LOGGER.audit("Delete load by load date is successfull.")
+    if(invalidLoadTimestamps.isEmpty) {
+      LOGGER.audit("Delete load by load date is successfull.")
+    }
+    else {
+      sys.error("Delete load by load date is failed. No matching load found.")
+    }
     Seq.empty
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/6701eeef/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java
----------------------------------------------------------------------
diff --git a/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java b/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java
index 8708779..48964ca 100644
--- a/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java
+++ b/processing/src/main/java/org/carbondata/lcm/status/SegmentStatusManager.java
@@ -253,12 +253,18 @@ public class SegmentStatusManager {
         listOfLoadFolderDetailsArray = readLoadMetadata(cubeFolderPath);
         if (listOfLoadFolderDetailsArray != null && listOfLoadFolderDetailsArray.length != 0) {
           updateDeletionStatus(loadIds, listOfLoadFolderDetailsArray, invalidLoadIds);
-          if (!invalidLoadIds.isEmpty()) {
-            LOG.warn("Load doesnt exist or it is already deleted , LoadSeqId-" + invalidLoadIds);
+          if(invalidLoadIds.isEmpty())
+          {
+            // All or None , if anything fails then dont write
+            writeLoadDetailsIntoFile(dataLoadLocation, listOfLoadFolderDetailsArray);
           }
-          writeLoadDetailsIntoFile(dataLoadLocation, listOfLoadFolderDetailsArray);
+          else
+          {
+            return invalidLoadIds;
+          }
+
         } else {
-          LOG.warn("Load doesnt exist or it is already deleted , LoadSeqId-" + loadIds);
+          LOG.audit("Delete load by Id is failed. No matching load id found.");
           return loadIds;
         }
 
@@ -307,24 +313,16 @@ public class SegmentStatusManager {
         if (listOfLoadFolderDetailsArray != null && listOfLoadFolderDetailsArray.length != 0) {
           updateDeletionStatus(loadDate, listOfLoadFolderDetailsArray,
               invalidLoadTimestamps, loadStartTime);
-          if (!invalidLoadTimestamps.isEmpty()) {
-            LOG.warn("Load doesnt exist or it is already deleted , LoadTimestamps-"
-                + invalidLoadTimestamps);
-            if (invalidLoadTimestamps.size() == listOfLoadFolderDetailsArray.length) {
-              LOG.audit(
-                  "The delete load by Id is failed. Failed to delete the following load(s)."
-                      + " LoadSeqId-" + invalidLoadTimestamps);
-              LOG.error("Error message: "
-                  + "Load deletion is failed. Failed to delete the following load(s). LoadSeqId-" +
-                  invalidLoadTimestamps);
-
-            }
+          if(invalidLoadTimestamps.isEmpty()) {
+            writeLoadDetailsIntoFile(dataLoadLocation, listOfLoadFolderDetailsArray);
+          }
+          else
+          {
+            return invalidLoadTimestamps;
           }
-
-          writeLoadDetailsIntoFile(dataLoadLocation, listOfLoadFolderDetailsArray);
 
         } else {
-          LOG.warn("Load doesnt exist or it is already deleted , LoadTimestamp-" + loadDate);
+          LOG.audit("Delete load by date is failed. No matching load found.");
           invalidLoadTimestamps.add(loadDate);
           return invalidLoadTimestamps;
         }
@@ -383,7 +381,7 @@ public class SegmentStatusManager {
    * @param invalidLoadIds
    * @return invalidLoadIds
    */
-  public void updateDeletionStatus(List<String> loadIds,
+  public List<String> updateDeletionStatus(List<String> loadIds,
       LoadMetadataDetails[] listOfLoadFolderDetailsArray, List<String> invalidLoadIds) {
     for (String loadId : loadIds) {
       boolean loadFound = false;
@@ -393,26 +391,24 @@ public class SegmentStatusManager {
       for (LoadMetadataDetails loadMetadata : listOfLoadFolderDetailsArray) {
 
         if (loadId.equalsIgnoreCase(loadMetadata.getLoadName())) {
-          loadFound = true;
           if (!CarbonCommonConstants.MARKED_FOR_DELETE.equals(loadMetadata.getLoadStatus())) {
+            loadFound = true;
             loadMetadata.setLoadStatus(CarbonCommonConstants.MARKED_FOR_DELETE);
             loadMetadata.setModificationOrdeletionTimesStamp(readCurrentTime());
             LOG.info("LoadId " + loadId + " Marked for Delete");
-          } else {
-            // it is already deleted . can not delete it again.
-            invalidLoadIds.add(loadId);
           }
-
           break;
         }
       }
 
       if (!loadFound) {
+        LOG.audit("Delete load by Id is failed. No matching load id found.");
         invalidLoadIds.add(loadId);
+        return invalidLoadIds;
       }
 
     }
-
+    return invalidLoadIds;
   }
 
   /**
@@ -423,7 +419,7 @@ public class SegmentStatusManager {
    * @param invalidLoadTimestamps
    * @return invalidLoadTimestamps
    */
-  public void updateDeletionStatus(String loadDate,
+  public List<String> updateDeletionStatus(String loadDate,
       LoadMetadataDetails[] listOfLoadFolderDetailsArray, List<String> invalidLoadTimestamps,
       Long loadStartTime) {
     // For each load timestamp loop through data and if the
@@ -433,28 +429,25 @@ public class SegmentStatusManager {
     String loadStartTimeString = "Load Start Time: ";
     for (LoadMetadataDetails loadMetadata : listOfLoadFolderDetailsArray) {
       Integer result = compareDateValues(loadMetadata.getLoadStartTimeAsLong(), loadStartTime);
-      if (null == result) {
-        invalidLoadTimestamps.add(loadDate);
-      } else if (result < 0) {
-        loadFound = true;
+      if (result < 0) {
         if (!CarbonCommonConstants.MARKED_FOR_DELETE.equals(loadMetadata.getLoadStatus())) {
+          loadFound = true;
           loadMetadata.setLoadStatus(CarbonCommonConstants.MARKED_FOR_DELETE);
           loadMetadata.setModificationOrdeletionTimesStamp(readCurrentTime());
           LOG.info("Info: " +
               loadStartTimeString + loadMetadata.getLoadStartTime() +
               " Marked for Delete");
-        } else {
-          // it is already deleted . can not delete it again.
-          invalidLoadTimestamps.add(loadMetadata.getLoadStartTime());
         }
       }
+
     }
 
     if (!loadFound) {
       invalidLoadTimestamps.add(loadDate);
-
+      LOG.audit("Delete load by date is failed. No matching load found.");
+      return invalidLoadTimestamps;
     }
-
+    return invalidLoadTimestamps;
   }
 
   /**