Github user manishgupta88 commented on a diff in the pull request:

    
https://github.com/apache/incubator-carbondata/pull/841#discussion_r113147015
  
    --- Diff: 
integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/AlterTableCommands.scala
 ---
    @@ -51,15 +52,15 @@ private[sql] case class AlterTableAddColumns(
         LOGGER.audit(s"Alter table add columns request has been received for 
$dbName.$tableName")
         val locksToBeAcquired = List(LockUsage.METADATA_LOCK, 
LockUsage.COMPACTION_LOCK)
         var locks = List.empty[ICarbonLock]
    -    var lastUpdatedTime = 0L
    +    var timeStamp = 0L
         var newCols = 
Seq[org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema]()
    -    val carbonTable = CarbonEnv.getInstance(sparkSession).carbonMetastore
    -      .lookupRelation(Some(dbName), 
tableName)(sparkSession).asInstanceOf[CarbonRelation].tableMeta
    -      .carbonTable
    +    var carbonTable: CarbonTable = null
         try {
    -      lastUpdatedTime = carbonTable.getTableLastUpdatedTime
           locks = AlterTableUtil
             .validateTableAndAcquireLock(dbName, tableName, 
locksToBeAcquired)(sparkSession)
    +      carbonTable = CarbonEnv.getInstance(sparkSession).carbonMetastore
    --- End diff --
    
    Add a comment here
    "Consider a concurrent scenario where 2 alter operations are executed in 
parallel. 1st operation is success and updates the schema file. 2nd operation 
will get the lock after completion of 1st operation but as look up relation is 
called before it will have the older carbon table and this can lead to 
inconsistent state in the system. Therefor look up relation should be called 
after acquiring the lock"


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to