carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [42/50] [abbrv] carbondata git commit: [CARBONDATA-1912] Handling lock issues for alter rename operation
Date Sun, 07 Jan 2018 03:05:50 GMT
[CARBONDATA-1912] Handling lock issues for alter rename operation

Modified code to release all old table acquired locks in case of any exception. So release
all old table locks only in case of any exception instead of unlocking in finally block

This closes #1734


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

Branch: refs/heads/carbonstore
Commit: 7a4bd2298557ff76ee29d6c8efa37c604b548a07
Parents: 6f10c41
Author: Manohar <manohar.crazy09@gmail.com>
Authored: Thu Jan 4 14:39:25 2018 +0530
Committer: manishgupta88 <tomanishgupta18@gmail.com>
Committed: Fri Jan 5 10:25:10 2018 +0530

----------------------------------------------------------------------
 .../command/schema/CarbonAlterTableRenameCommand.scala    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/7a4bd229/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
index bbd3f3a..64d1d6f 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
@@ -80,12 +80,15 @@ private[sql] case class CarbonAlterTableRenameCommand(
     var locks = List.empty[ICarbonLock]
     var timeStamp = 0L
     var carbonTable: CarbonTable = null
+    // lock file path to release locks after operation
+    var carbonTableLockFilePath: String = null
     try {
       locks = AlterTableUtil
         .validateTableAndAcquireLock(oldDatabaseName, oldTableName, locksToBeAcquired)(
           sparkSession)
       carbonTable = metastore.lookupRelation(Some(oldDatabaseName), oldTableName)(sparkSession)
         .asInstanceOf[CarbonRelation].carbonTable
+      carbonTableLockFilePath = carbonTable.getTablePath
       // if any load is in progress for table, do not allow rename table
       if (SegmentStatusManager.checkIfAnyLoadInProgressForTable(carbonTable)) {
         throw new AnalysisException(s"Data loading is in progress for table $oldTableName,
alter " +
@@ -151,6 +154,7 @@ private[sql] case class CarbonAlterTableRenameCommand(
 
       sparkSession.catalog.refreshTable(TableIdentifier(newTableName,
         Some(oldDatabaseName)).quotedString)
+      carbonTableLockFilePath = newTablePath
       LOGGER.audit(s"Table $oldTableName has been successfully renamed to $newTableName")
       LOGGER.info(s"Table $oldTableName has been successfully renamed to $newTableName")
     } catch {
@@ -166,20 +170,16 @@ private[sql] case class CarbonAlterTableRenameCommand(
               sparkSession)
           renameBadRecords(newTableName, oldTableName, oldDatabaseName)
         }
-        // release lock from old location in case of any rename failure
-        AlterTableUtil.releaseLocks(locks)
         sys.error(s"Alter table rename table operation failed: ${e.getMessage}")
     } finally {
       // case specific to rename table as after table rename old table path will not be found
       if (carbonTable != null) {
-        val newTablePath = CarbonUtil
-          .getNewTablePath(new Path(carbonTable.getTablePath), newTableName)
         AlterTableUtil
           .releaseLocksManually(locks,
             locksToBeAcquired,
             oldDatabaseName,
             newTableName,
-            newTablePath)
+            carbonTableLockFilePath)
       }
     }
     Seq.empty


Mime
View raw message