You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "slfan1989 (via GitHub)" <gi...@apache.org> on 2023/05/29 15:14:26 UTC

[GitHub] [hadoop] slfan1989 commented on a diff in pull request #5673: YARN-8337. [FederationStateStore - MySql] Improve ApplicationHome Mysql Script.

slfan1989 commented on code in PR #5673:
URL: https://github.com/apache/hadoop/pull/5673#discussion_r1209399807


##########
hadoop-yarn-project/hadoop-yarn/bin/FederationStateStore/MySQL/FederationStateStoreStoredProcs.sql:
##########
@@ -92,12 +92,9 @@ CREATE PROCEDURE sp_addApplicationHomeSubCluster(
    IN applicationContext_IN BLOB,
    OUT storedHomeSubCluster_OUT varchar(256), OUT rowCount_OUT int)
 BEGIN
-   INSERT INTO applicationsHomeSubCluster
-      (applicationId, homeSubCluster, createTime, applicationContext)
-      (SELECT applicationId_IN, homeSubCluster_IN, NOW(), applicationContext_IN
-       FROM applicationsHomeSubCluster
-       WHERE applicationId = applicationId_IN
-       HAVING COUNT(*) = 0 );
+   INSERT IGNORE INTO applicationsHomeSubCluster(

Review Comment:
   Thank you very much for helping to review this pr! 
   
   `YARN-8337` describes a scenario where we use the Mysql database, and when multiple sessions call the sp_addApplicationHomeSubCluster stored procedure at the same time, a deadlock may occur.
   
   MySQL Gap lock is a type of gap lock used to protect a range of gaps instead of specific data rows.  We can look at the following picture.
   
   <img width="684" alt="image" src="https://github.com/apache/hadoop/assets/55643692/bef31a2d-20b7-40b8-a007-0b3d07bffc65">
   
   
   



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org