You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by GitBox <gi...@apache.org> on 2022/05/10 04:04:08 UTC

[GitHub] [incubator-linkis] peacewong opened a new pull request, #2100: Fix the deadlock issue of Manager db under high concurrency

peacewong opened a new pull request, #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100

   ### What is the purpose of the change
   close #2099
   
   ### Brief change log
   - Fix Deadlock issue that update label keyValue
   


-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] wForget commented on a diff in pull request #2100: Fix the deadlock issue of Manager db under high concurrency

Posted by GitBox <gi...@apache.org>.
wForget commented on code in PR #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100#discussion_r868799099


##########
linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/persistence/impl/DefaultLabelManagerPersistence.java:
##########
@@ -113,15 +114,26 @@ public void removeLabel(PersistenceLabel persistenceLabel) {
 
     @Override
     public void updateLabel(int id, PersistenceLabel persistenceLabel) {
-        // 1.更新label表
-        // 2.删掉value
-        // 3.更新labelValue
-        // TODO: 2020/10/12  updateLabel 要重写判空
         persistenceLabel.setUpdateTime(new Date());
         labelManagerMapper.updateLabel(id, persistenceLabel);
         labelManagerMapper.deleteLabelKeyVaules(id);
         if (!persistenceLabel.getValue().isEmpty()) {
-            labelManagerMapper.registerLabelKeyValues(persistenceLabel.getValue(), id);
+            replaceIntoLabelKeyValues(persistenceLabel.getValue(), id);
+        }
+    }
+
+    private void replaceIntoLabelKeyValues(
+            Map<String, String> labelValueKeyAndContent, int labelId) {
+        if (null != labelValueKeyAndContent && labelId > 0) {
+            Iterator<Map.Entry<String, String>> iterator =
+                    labelValueKeyAndContent.entrySet().iterator();
+            while (iterator.hasNext()) {

Review Comment:
   use foreach? like:
   ```
   for(Map.Entry<String, String> labelKeyValue: labelValueKeyAndContent.entrySet())
   ```



-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] peacewong commented on a diff in pull request #2100: Fix the deadlock issue of Manager db under high concurrency

Posted by GitBox <gi...@apache.org>.
peacewong commented on code in PR #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100#discussion_r868857476


##########
linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/persistence/impl/DefaultLabelManagerPersistence.java:
##########
@@ -113,15 +114,26 @@ public void removeLabel(PersistenceLabel persistenceLabel) {
 
     @Override
     public void updateLabel(int id, PersistenceLabel persistenceLabel) {
-        // 1.更新label表
-        // 2.删掉value
-        // 3.更新labelValue
-        // TODO: 2020/10/12  updateLabel 要重写判空
         persistenceLabel.setUpdateTime(new Date());
         labelManagerMapper.updateLabel(id, persistenceLabel);
         labelManagerMapper.deleteLabelKeyVaules(id);
         if (!persistenceLabel.getValue().isEmpty()) {
-            labelManagerMapper.registerLabelKeyValues(persistenceLabel.getValue(), id);
+            replaceIntoLabelKeyValues(persistenceLabel.getValue(), id);
+        }
+    }
+
+    private void replaceIntoLabelKeyValues(
+            Map<String, String> labelValueKeyAndContent, int labelId) {
+        if (null != labelValueKeyAndContent && labelId > 0) {
+            Iterator<Map.Entry<String, String>> iterator =
+                    labelValueKeyAndContent.entrySet().iterator();
+            while (iterator.hasNext()) {

Review Comment:
   > use foreach? like:
   > 
   > ```
   > for(Map.Entry<String, String> labelKeyValue: labelValueKeyAndContent.entrySet())
   > ```
   
   It is better to use iterator for map iteration, considering safety and performance



-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] wForget merged pull request #2100: Fix the deadlock issue of Manager db under high concurrency

Posted by GitBox <gi...@apache.org>.
wForget merged PR #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100


-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] codecov[bot] commented on pull request #2100: Fix the deadlock issue of Manager db under high concurrency

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100#issuecomment-1121903168

   # [Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2100?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2100](https://codecov.io/gh/apache/incubator-linkis/pull/2100?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (33e8d8a) into [dev-1.1.2](https://codecov.io/gh/apache/incubator-linkis/commit/b096014d0de504371ee5ec6bf8f8180dd69173a5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b096014) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             dev-1.1.2    #2100   +/-   ##
   ============================================
     Coverage        18.45%   18.45%           
     Complexity         703      703           
   ============================================
     Files              344      344           
     Lines            10723    10723           
     Branches          1608     1608           
   ============================================
     Hits              1979     1979           
     Misses            8539     8539           
     Partials           205      205           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2100?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-linkis/pull/2100?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b096014...33e8d8a](https://codecov.io/gh/apache/incubator-linkis/pull/2100?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org


[GitHub] [incubator-linkis] wForget commented on a diff in pull request #2100: Fix the deadlock issue of Manager db under high concurrency

Posted by GitBox <gi...@apache.org>.
wForget commented on code in PR #2100:
URL: https://github.com/apache/incubator-linkis/pull/2100#discussion_r868895652


##########
linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/persistence/impl/DefaultLabelManagerPersistence.java:
##########
@@ -113,15 +114,26 @@ public void removeLabel(PersistenceLabel persistenceLabel) {
 
     @Override
     public void updateLabel(int id, PersistenceLabel persistenceLabel) {
-        // 1.更新label表
-        // 2.删掉value
-        // 3.更新labelValue
-        // TODO: 2020/10/12  updateLabel 要重写判空
         persistenceLabel.setUpdateTime(new Date());
         labelManagerMapper.updateLabel(id, persistenceLabel);
         labelManagerMapper.deleteLabelKeyVaules(id);
         if (!persistenceLabel.getValue().isEmpty()) {
-            labelManagerMapper.registerLabelKeyValues(persistenceLabel.getValue(), id);
+            replaceIntoLabelKeyValues(persistenceLabel.getValue(), id);
+        }
+    }
+
+    private void replaceIntoLabelKeyValues(
+            Map<String, String> labelValueKeyAndContent, int labelId) {
+        if (null != labelValueKeyAndContent && labelId > 0) {
+            Iterator<Map.Entry<String, String>> iterator =
+                    labelValueKeyAndContent.entrySet().iterator();
+            while (iterator.hasNext()) {

Review Comment:
   got it, thanks.



-- 
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: notifications-unsubscribe@linkis.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org