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:20:26 UTC

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

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