Copilot commented on code in PR #14310:
URL: https://github.com/apache/cloudstack/pull/14310#discussion_r4193085590


##########
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java:
##########
@@ -546,6 +549,7 @@ public boolean removeVMFromBackupOffering(final Long vmId, 
final boolean forced)
                     
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_BACKUP_OFFERING_REMOVED_AND_BACKUPS_DELETED,
 vm.getAccountId(), vm.getDataCenterId(), vm.getId(),
                             "Backup-" + vm.getHostName() + "-" + vm.getUuid(), 
backupOfferingId, null, null,
                             Backup.class.getSimpleName(), vm.getUuid());
+                    backupUsageMetricDao.removeByVmAndOffering(vm.getId(), 
backupOfferingId);

Review Comment:
   Commit the deletion usage event and removal of its last-published metric in 
one transaction. If the process stops after the event row commits but before 
this delete, reassigning the same offering after its size returns to the stale 
value suppresses the first metric, leaving the new `usage_backup` row at zero 
until another size change. Wrap both operations in `Transaction.execute`, as 
`publishBackupUsageMetricIfChanged` does.
   
   This issue also appears on line 1660 of the same file.



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