weizhouapache commented on code in PR #11095:
URL: https://github.com/apache/cloudstack/pull/11095#discussion_r2337146824


##########
server/src/main/java/com/cloud/alert/AlertManagerImpl.java:
##########
@@ -290,8 +294,13 @@ protected void recalculateHostCapacities() {
                 Math.min(CapacityManager.CapacityCalculateWorkers.value(), 
hostIds.size())));
         for (Long hostId : hostIds) {
             futures.put(hostId, executorService.submit(() -> {
-                final HostVO host = hostDao.findById(hostId);
-                _capacityMgr.updateCapacityForHost(host);
+                Transaction.execute(new TransactionCallbackNoReturn() {
+                    @Override
+                    public void doInTransactionWithoutResult(TransactionStatus 
status) {
+                        final HostVO host = hostDao.findById(hostId);
+                        _capacityMgr.updateCapacityForHost(host);

Review Comment:
   @shwstppr 
   I noticed an exception in the management-server.log which seems to be 
related to this change
   
   ```
   2025-09-10 15:22:10,998 ERROR [o.a.c.f.m.MessageBusBase] 
(pool-18-thread-1:[]) (logid:) NO EVENT PUBLISH CAN BE WRAPPED WITHIN DB 
TRANSACTION! com.cloud.utils.exception.CloudRuntimeException: NO EVENT PUBLISH 
CAN BE WRAPPED WITHIN DB TRANSACTION!
           at 
org.apache.cloudstack.framework.messagebus.MessageBusBase.publish(MessageBusBase.java:168)
           at 
com.cloud.capacity.CapacityManagerImpl.updateCapacityForHost(CapacityManagerImpl.java:774)
           at 
com.cloud.alert.AlertManagerImpl$1.doInTransactionWithoutResult(AlertManagerImpl.java:301)
           at 
com.cloud.utils.db.TransactionCallbackNoReturn.doInTransaction(TransactionCallbackNoReturn.java:25)
           at 
com.cloud.utils.db.Transaction$2.doInTransaction(Transaction.java:48)
           at com.cloud.utils.db.Transaction.execute(Transaction.java:38)
           at com.cloud.utils.db.Transaction.execute(Transaction.java:45)
           at 
com.cloud.alert.AlertManagerImpl.lambda$recalculateHostCapacities$0(AlertManagerImpl.java:297)
           at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
           at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
           at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
           at java.base/java.lang.Thread.run(Thread.java:840)
   ```



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