ustcweizhou commented on a change in pull request #3204: server: Fix exception 
while update domain resource count
URL: https://github.com/apache/cloudstack/pull/3204#discussion_r277981836
 
 

 ##########
 File path: 
engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
 ##########
 @@ -276,17 +276,18 @@ public long countMemoryAllocatedToAccount(long 
accountId) {
     }
 
     private long executeSqlCountComputingResourcesForAccount(long accountId, 
String sqlCountComputingResourcesAllocatedToAccount) {
-        try (TransactionLegacy tx = TransactionLegacy.currentTxn()) {
+        TransactionLegacy tx = TransactionLegacy.currentTxn();
+        try {
             PreparedStatement pstmt = 
tx.prepareAutoCloseStatement(sqlCountComputingResourcesAllocatedToAccount);
             pstmt.setLong(1, accountId);
 
             ResultSet rs = pstmt.executeQuery();
             if (!rs.next()) {
-              throw new CloudRuntimeException(String.format("An unexpected 
case happened while counting allocated computing resources for account: " + 
accountId));
+                return 0L;
             }
             return rs.getLong("total");
         } catch (SQLException e) {
             throw new CloudRuntimeException(e);
 
 Review comment:
   @GabrielBrascher actually it is not an error. rs.next() is false means the 
sql query returns null (for example, no vm in the domain/account). If there are 
something wrong in the sql query, they are handled in line 290.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to