qiuchenjian commented on a change in pull request #3166: [CARBONDATA-3332] Blocked concurrent compaction and update
URL:
https://github.com/apache/carbondata/pull/3166#discussion_r269868206
##########
File path: integration/spark2/src/main/scala/org/apache/carbondata/spark/rdd/CarbonDataRDDFactory.scala
##########
@@ -867,27 +868,34 @@ object CarbonDataRDDFactory {
val lock = CarbonLockFactory.getCarbonLockObj(
carbonTable.getAbsoluteTableIdentifier,
LockUsage.COMPACTION_LOCK)
-
- if (lock.lockWithRetries()) {
- LOGGER.info("Acquired the compaction lock.")
- try {
- startCompactionThreads(sqlContext,
- carbonLoadModel,
- storeLocation,
- compactionModel,
- lock,
- compactedSegments,
- operationContext
- )
- } catch {
- case e: Exception =>
- LOGGER.error(s"Exception in start compaction thread. ${ e.getMessage }")
- lock.unlock()
- throw e
+ val updateLock = CarbonLockFactory.getCarbonLockObj(carbonTable
+ .getAbsoluteTableIdentifier, LockUsage.UPDATE_LOCK)
+ try {
+ if (updateLock.lockWithRetries()) {
+ if (lock.lockWithRetries()) {
+ LOGGER.info("Acquired the compaction lock.")
+ startCompactionThreads(sqlContext,
+ carbonLoadModel,
+ storeLocation,
+ compactionModel,
+ lock,
+ compactedSegments,
+ operationContext
+ )
+ } else {
+ LOGGER.error("Not able to acquire the compaction lock for table " +
+ s"${ carbonLoadModel.getDatabaseName }.${ carbonLoadModel.getTableName}")
+ }
+ } else {
+ throw new ConcurrentOperationException(carbonTable, "update", "compaction")
}
- } else {
- LOGGER.error("Not able to acquire the compaction lock for table " +
- s"${ carbonLoadModel.getDatabaseName }.${ carbonLoadModel.getTableName}")
+ } catch {
+ case e: Exception =>
+ LOGGER.error(s"Exception in start compaction thread.", e)
+ lock.unlock()
+ throw e
+ } finally {
+ updateLock.unlock()
Review comment:
@kunal642 Can we set a timeout of lock file, if the lock is timeout, we will clean it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[hidden email]
With regards,
Apache Git Services