dengzhhu653 commented on code in PR #6159:
URL: https://github.com/apache/hive/pull/6159#discussion_r2523496256


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java:
##########
@@ -424,24 +451,34 @@ public String isWithinCheckInterval(String expr, long 
intervalInSeconds) throws
     return condition;
   }
 
-  public String addForUpdateClause(String selectStatement) throws 
MetaException {
+  public String addForUpdateClause(String selectStatement, boolean noWait) 
throws MetaException {
     switch (dbType) {
     case DERBY:
       //https://db.apache.org/derby/docs/10.1/ref/rrefsqlj31783.html
       //sadly in Derby, FOR UPDATE doesn't meant what it should
       return selectStatement;
-    case MYSQL:
-      //http://dev.mysql.com/doc/refman/5.7/en/select.html
     case ORACLE:
       //https://docs.oracle.com/cd/E17952_01/refman-5.6-en/select.html
     case POSTGRES:
       //http://www.postgresql.org/docs/9.0/static/sql-select.html
     case CUSTOM: // ANSI SQL
+      return selectStatement + " for update" + (noWait ? " NOWAIT" : "");
+    case MYSQL:
+      //http://dev.mysql.com/doc/refman/5.7/en/select.html
+      if (noWait) {
+        if (canMySQLSupportNoWait()) {
+          return selectStatement + " for update NOWAIT";
+        } else {
+          int selectLength = "select".length();
+          return selectStatement.trim().substring(0, selectLength) + " /*+ 
MAX_EXECUTION_TIME(300) */ " +

Review Comment:
   it takes the row-level lock as well, and maximum wait time for the lock is 
300ms, otherwise throws:
   ```
   Caused by: java.sql.SQLException: Query execution was interrupted, maximum 
statement execution time exceeded
   ```
   
   Checked MySQL 5.7, using mysql-connector-j-8.0.32.jar and 
mysql-connector-java-5.1.49.jar



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