You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@carbondata.apache.org by ravikiran23 <gi...@git.apache.org> on 2016/08/31 17:50:08 UTC

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

GitHub user ravikiran23 opened a pull request:

    https://github.com/apache/incubator-carbondata/pull/116

    [CARBONDATA-198] System level lock feature for compaction.

    1. implemented system level compaction lock feature.
    2. made the DDL call to compaction as blocking call.
    3. handled the requests which are received during one compaction and taking those requests later.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ravikiran23/incubator-carbondata compSystemlevelLock

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-carbondata/pull/116.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #116
    
----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77129093
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -333,7 +531,7 @@ object CarbonDataRDDFactory extends Logging {
               )
         }
     
    -    var loadsToMerge = CarbonDataMergerUtil.identifySegmentsToBeMerged(
    +    val loadsToMerge = CarbonDataMergerUtil.identifySegmentsToBeMerged(
    --- End diff --
    
    this condition is not required before thread launch


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77130739
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -297,15 +366,144 @@ object CarbonDataRDDFactory extends Logging {
         }
         else {
           logger
    -        .audit("Not able to acquire the compaction lock for table " +
    +        .audit("Not able to acquire the system level compaction lock for table " +
               s"${carbonLoadModel.getDatabaseName}.${carbonLoadModel.getTableName}"
             )
           logger
             .error("Not able to acquire the compaction lock for table " + carbonLoadModel
               .getDatabaseName + "." + carbonLoadModel.getTableName
             )
    -      sys.error("Table is already locked for compaction. Please try after some time.")
    +      if (!CarbonCompactionUtil
    +        .createCompactionRequiredFile(carbonTable.getMetaDataFilepath, compactionType)) {
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77131782
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -333,7 +531,7 @@ object CarbonDataRDDFactory extends Logging {
               )
         }
     
    -    var loadsToMerge = CarbonDataMergerUtil.identifySegmentsToBeMerged(
    +    val loadsToMerge = CarbonDataMergerUtil.identifySegmentsToBeMerged(
    --- End diff --
    
    fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77127755
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -297,15 +366,144 @@ object CarbonDataRDDFactory extends Logging {
         }
         else {
           logger
    -        .audit("Not able to acquire the compaction lock for table " +
    +        .audit("Not able to acquire the system level compaction lock for table " +
               s"${carbonLoadModel.getDatabaseName}.${carbonLoadModel.getTableName}"
             )
           logger
             .error("Not able to acquire the compaction lock for table " + carbonLoadModel
               .getDatabaseName + "." + carbonLoadModel.getTableName
             )
    -      sys.error("Table is already locked for compaction. Please try after some time.")
    +      if (!CarbonCompactionUtil
    +        .createCompactionRequiredFile(carbonTable.getMetaDataFilepath, compactionType)) {
    --- End diff --
    
    move printing log to  function


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77119210
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java ---
    @@ -904,6 +904,27 @@
        */
       public static final int DEFAULT_CARBON_BLOCKLETDISTRIBUTION_MIN_REQUIRED_SIZE = 2;
     
    +  /**
    +   * File created in case of minor compaction request
    +   */
    +  public static String minorCompactionRequiredFile = "compactionRequired_minor";
    +
    +  /**
    +   * File created in case of major compaction request
    +   */
    +  public static String majorCompactionRequiredFile = "compactionRequired_major";
    +
    +  /**
    +   * Property for enabling system level compaction lock.1 compaction can run at once.
    +   */
    +  public static String ENABLE_SYSTEM_LEVEL_COMPACTION_LOCK =
    +      "carbon.enable.systemlevel.compaction.lock";
    --- End diff --
    
    fixed. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77131071
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -297,15 +366,144 @@ object CarbonDataRDDFactory extends Logging {
         }
         else {
           logger
    -        .audit("Not able to acquire the compaction lock for table " +
    +        .audit("Not able to acquire the system level compaction lock for table " +
               s"${carbonLoadModel.getDatabaseName}.${carbonLoadModel.getTableName}"
             )
           logger
             .error("Not able to acquire the compaction lock for table " + carbonLoadModel
               .getDatabaseName + "." + carbonLoadModel.getTableName
             )
    -      sys.error("Table is already locked for compaction. Please try after some time.")
    +      if (!CarbonCompactionUtil
    +        .createCompactionRequiredFile(carbonTable.getMetaDataFilepath, compactionType)) {
    +        logger.error("Not able to create a compaction required file for table " + carbonLoadModel
    +          .getDatabaseName + "." + carbonLoadModel.getTableName
    +        )
    +      }
    +      else {
    +        logger
    +          .info("successfully created a compaction required file for table " + carbonLoadModel
    +            .getDatabaseName + "." + carbonLoadModel.getTableName
    +          )
    +      }
    +      sys.error("System is already locked for compaction. Please try after some time.")
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-carbondata/pull/116


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77129488
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -400,43 +631,36 @@ object CarbonDataRDDFactory extends Logging {
                 compactionLock.unlock()
               }
             }
    -      }.start
    +      }
    +      if(compactionModel.isDDLTrigger) {
    +        // making this an blocking call for DDL
    +        compactionThread.run()
    +      }
    +      else {
    +        // non blocking call in case of auto compaction.
    +        compactionThread.start()
    +      }
         }
         else {
           compactionLock.unlock()
    --- End diff --
    
    check if any exception is possible , if needed to be moved to finally


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77134335
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -400,43 +631,36 @@ object CarbonDataRDDFactory extends Logging {
                 compactionLock.unlock()
               }
             }
    -      }.start
    +      }
    +      if(compactionModel.isDDLTrigger) {
    +        // making this an blocking call for DDL
    +        compactionThread.run()
    +      }
    +      else {
    +        // non blocking call in case of auto compaction.
    +        compactionThread.start()
    +      }
         }
         else {
           compactionLock.unlock()
    --- End diff --
    
    fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77044909
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java ---
    @@ -904,6 +904,27 @@
        */
       public static final int DEFAULT_CARBON_BLOCKLETDISTRIBUTION_MIN_REQUIRED_SIZE = 2;
     
    +  /**
    +   * File created in case of minor compaction request
    +   */
    +  public static String minorCompactionRequiredFile = "compactionRequired_minor";
    +
    +  /**
    +   * File created in case of major compaction request
    +   */
    +  public static String majorCompactionRequiredFile = "compactionRequired_major";
    +
    +  /**
    +   * Property for enabling system level compaction lock.1 compaction can run at once.
    +   */
    +  public static String ENABLE_SYSTEM_LEVEL_COMPACTION_LOCK =
    +      "carbon.enable.systemlevel.compaction.lock";
    --- End diff --
    
    change configuration to "carbon.concurrent.compaction" default to false. i.e., no concurrent compaction allowed by default.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77044027
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -344,49 +540,77 @@ object CarbonDataRDDFactory extends Logging {
     
         if (loadsToMerge.size() > 1) {
     
    -      val sortedSegments: util.List[LoadMetadataDetails] = new util.ArrayList[LoadMetadataDetails](
    -        segList
    -      )
    -      CarbonDataMergerUtil.sortSegments(sortedSegments)
    -      val lastSegment = sortedSegments.get(sortedSegments.size()-1)
    -
    -      new Thread {
    +      val compactionThread = new Thread {
             override def run(): Unit = {
     
               try {
    -            while (loadsToMerge.size() > 1) {
    -              deletePartialLoadsInCompaction(carbonLoadModel)
    -              val futureList: util.List[Future[Void]] = new util.ArrayList[Future[Void]](
    -                CarbonCommonConstants
    -                  .DEFAULT_COLLECTION_SIZE
    -              )
    -
    -              scanSegmentsAndSubmitJob(futureList, loadsToMerge)
    -
    -              futureList.asScala.foreach(future => {
    -                future.get
    -              }
    -              )
    -
    -              // scan again and determine if anything is there to merge again.
    -              readLoadMetadataDetails(carbonLoadModel, hdfsStoreLocation)
    -              segList = carbonLoadModel.getLoadMetadataDetails
    -              // in case of major compaction we will scan only once and come out as it will keep
    -              // on doing major for the new loads also.
    -              // excluding the newly added segments.
    -              if (compactionModel.compactionType == CompactionType.MAJOR_COMPACTION) {
    -
    -                segList = CarbonDataMergerUtil
    -                  .filterOutNewlyAddedSegments(segList, loadsToMerge, lastSegment)
    +            executeCompaction(carbonLoadModel: CarbonLoadModel,
    +              hdfsStoreLocation: String,
    +              compactionModel: CompactionModel,
    +              partitioner: Partitioner,
    +              executor, sqlContext, kettleHomePath, storeLocation
    +            )
    +            // check for all the tables.
    +            val isSystemCompactionLockEnabled = CarbonProperties.getInstance()
    +              .getProperty(CarbonCommonConstants.ENABLE_SYSTEM_LEVEL_COMPACTION_LOCK, "false")
    +              .equalsIgnoreCase("true")
    +
    +            if (isSystemCompactionLockEnabled) {
    +              logger.info("System level compaction lock is enabled.")
    +              CarbonEnv.getInstance(sqlContext).carbonCatalog.metadata.tablesMeta.map { c =>
    --- End diff --
    
    provide getnexttabletocompact function 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by gvramana <gi...@git.apache.org>.
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77128213
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -297,15 +366,144 @@ object CarbonDataRDDFactory extends Logging {
         }
         else {
           logger
    -        .audit("Not able to acquire the compaction lock for table " +
    +        .audit("Not able to acquire the system level compaction lock for table " +
               s"${carbonLoadModel.getDatabaseName}.${carbonLoadModel.getTableName}"
             )
           logger
             .error("Not able to acquire the compaction lock for table " + carbonLoadModel
               .getDatabaseName + "." + carbonLoadModel.getTableName
             )
    -      sys.error("Table is already locked for compaction. Please try after some time.")
    +      if (!CarbonCompactionUtil
    +        .createCompactionRequiredFile(carbonTable.getMetaDataFilepath, compactionType)) {
    +        logger.error("Not able to create a compaction required file for table " + carbonLoadModel
    +          .getDatabaseName + "." + carbonLoadModel.getTableName
    +        )
    +      }
    +      else {
    +        logger
    +          .info("successfully created a compaction required file for table " + carbonLoadModel
    +            .getDatabaseName + "." + carbonLoadModel.getTableName
    +          )
    +      }
    +      sys.error("System is already locked for compaction. Please try after some time.")
    --- End diff --
    
    change message to "Compaction is in progress, compaction request for table "" in queue".
    Print error only during ddl trigger.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-carbondata pull request #116: [CARBONDATA-198] System level lock f...

Posted by ravikiran23 <gi...@git.apache.org>.
Github user ravikiran23 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/116#discussion_r77119222
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala ---
    @@ -344,49 +540,77 @@ object CarbonDataRDDFactory extends Logging {
     
         if (loadsToMerge.size() > 1) {
     
    -      val sortedSegments: util.List[LoadMetadataDetails] = new util.ArrayList[LoadMetadataDetails](
    -        segList
    -      )
    -      CarbonDataMergerUtil.sortSegments(sortedSegments)
    -      val lastSegment = sortedSegments.get(sortedSegments.size()-1)
    -
    -      new Thread {
    +      val compactionThread = new Thread {
             override def run(): Unit = {
     
               try {
    -            while (loadsToMerge.size() > 1) {
    -              deletePartialLoadsInCompaction(carbonLoadModel)
    -              val futureList: util.List[Future[Void]] = new util.ArrayList[Future[Void]](
    -                CarbonCommonConstants
    -                  .DEFAULT_COLLECTION_SIZE
    -              )
    -
    -              scanSegmentsAndSubmitJob(futureList, loadsToMerge)
    -
    -              futureList.asScala.foreach(future => {
    -                future.get
    -              }
    -              )
    -
    -              // scan again and determine if anything is there to merge again.
    -              readLoadMetadataDetails(carbonLoadModel, hdfsStoreLocation)
    -              segList = carbonLoadModel.getLoadMetadataDetails
    -              // in case of major compaction we will scan only once and come out as it will keep
    -              // on doing major for the new loads also.
    -              // excluding the newly added segments.
    -              if (compactionModel.compactionType == CompactionType.MAJOR_COMPACTION) {
    -
    -                segList = CarbonDataMergerUtil
    -                  .filterOutNewlyAddedSegments(segList, loadsToMerge, lastSegment)
    +            executeCompaction(carbonLoadModel: CarbonLoadModel,
    +              hdfsStoreLocation: String,
    +              compactionModel: CompactionModel,
    +              partitioner: Partitioner,
    +              executor, sqlContext, kettleHomePath, storeLocation
    +            )
    +            // check for all the tables.
    +            val isSystemCompactionLockEnabled = CarbonProperties.getInstance()
    +              .getProperty(CarbonCommonConstants.ENABLE_SYSTEM_LEVEL_COMPACTION_LOCK, "false")
    +              .equalsIgnoreCase("true")
    +
    +            if (isSystemCompactionLockEnabled) {
    +              logger.info("System level compaction lock is enabled.")
    +              CarbonEnv.getInstance(sqlContext).carbonCatalog.metadata.tablesMeta.map { c =>
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---