dengzhhu653 commented on PR #6159:
URL: https://github.com/apache/hive/pull/6159#issuecomment-3524602503

   
   Thank you @deniskuzZ  for the comment.
   ```sql
    String updateSQL = "UPDATE \"TABLE_PARAMS\" " +   "SET \"PARAM_VALUE\" = '" 
+ newVersion + "' " +
             "WHERE \"TBL_ID\" = " + tblId + " AND \"PARAM_KEY\" = '" + 
versionParamKey + "' " +
             AND \"PARAM_VALUE\" = '" + expectedVersion + "'";  // ✅ CHECK 
SNAPSHOT!
   ```
   The result of this query seems important to the example, let's say there is 
a row(`TBL_ID`, `PARAM_KEY`, `PARAM_VALUE`) (1, `hive.metastore.table.version`, 
1) on the table `TABLE_PARAMS`, if transaction A and B happens to execute the 
update(set hive.metastore.table.version = 2) at the same time, say if A takes 
the row lock, then B needs to wait for A committing or rollbacking to release 
the row before B is allowed to update this row, then B re-evaluates the `where` 
condition and see there is no row matched, then return 0.
   
   If there are more transactions to update this row, then they are piled up to 
get a change to take over the row lock. In my opinion, this is similar to the 
s4u way I proposed in the old PR.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to