DaanHoogland commented on code in PR #13915:
URL: https://github.com/apache/cloudstack/pull/13915#discussion_r3903701683


##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -1810,11 +1953,12 @@ public void 
doInTransactionWithoutResult(TransactionStatus status) {
                 if (CollectionUtils.isEmpty(tags)) {
                     return;
                 }
-                for (String tag : tags) {
-                    incrementResourceCountWithTag(accountId, 
ResourceType.volume, tag);
-                    if (size != null) {
-                        incrementResourceCountWithTag(accountId, 
ResourceType.primary_storage, tag, size);
-                    }
+                // Single batched UPDATE per ResourceType across the full 
(untagged + tagged) tag list,
+                // instead of one UPDATE per tag. Cuts the in-transaction 
row-lock acquire chain in half
+                // and avoids cross-tag waits exceeding 
innodb_lock_wait_timeout under concurrent restores.

Review Comment:
   can we move this to javadoc (preferably on a new method)



##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -1991,9 +2133,9 @@ public void 
incrementVolumePrimaryStorageResourceCount(long accountId, Boolean d
         if (CollectionUtils.isEmpty(tags)) {
             return;
         }
-        for (String tag : tags) {
-            incrementResourceCountWithTag(accountId, 
ResourceType.primary_storage, tag, size);
-        }
+        // Batched: one UPDATE across all (untagged + tagged) rows for 
primary_storage. Same rationale
+        // as incrementVolumeResourceCount — reduces in-transaction 
lock-acquire chain on resize paths.

Review Comment:
   can we move this to javadoc (preferably on a new method)



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

Reply via email to