Skip to content

Conversation

abh1sar
Copy link
Collaborator

@abh1sar abh1sar commented Aug 27, 2025

Description

  • Due to a bug in UsageBackupDaoImpl.removeUsage, entry in the cloud_usage.backup_usage doesn't get removed even after all the backups have been deleted and backup offering removed.
  • Backup usage doesn't get updated to 0 size when all backups are deleted.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Before Fix:

10:03:37.297 [Usage-Job-1] ERROR com.cloud.usage.dao.UsageBackupDaoImpl_EnhancerByCloudStack_c6b7eb21 - Exception caught while removing UsageBackupVO: Remove backup usage exception: No value specified for parameter 4
com.cloud.exception.CloudException: Remove backup usage exception: No value specified for parameter 4                                                                                     
        at com.cloud.usage.dao.UsageBackupDaoImpl.removeUsage(UsageBackupDaoImpl.java:76) ~[cloud-engine-schema-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]                                  
        at com.cloud.usage.dao.UsageBackupDaoImpl_EnhancerByCloudStack_c6b7eb21.CGLIB$removeUsage$0(<generated>) ~[cloud-engine-schema-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]           
        at com.cloud.usage.dao.UsageBackupDaoImpl_EnhancerByCloudStack_c6b7eb21_FastClassByCloudStack_515fb514.invoke(<generated>) ~[cloud-engine-schema-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[cglib-nodep-3.3.0.jar:?]                                                                                    
        at com.cloud.utils.component.ComponentInstantiationPostProcessor$InterceptorDispatcher.intercept(ComponentInstantiationPostProcessor.java:123) ~[cloud-utils-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at com.cloud.usage.dao.UsageBackupDaoImpl_EnhancerByCloudStack_c6b7eb21.removeUsage(<generated>) ~[cloud-engine-schema-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]                   
        at com.cloud.usage.UsageManagerImpl.createBackupEvent(UsageManagerImpl.java:2077) ~[classes/:?]                                                                                   
        at com.cloud.usage.UsageManagerImpl.createHelperRecord(UsageManagerImpl.java:986) ~[classes/:?]                                                                                   
        at com.cloud.usage.UsageManagerImpl.parse(UsageManagerImpl.java:716) ~[classes/:?]                                                                                                
        at com.cloud.usage.UsageManagerImpl.runInContextInternal(UsageManagerImpl.java:432) ~[classes/:?]                                                                      
        at com.cloud.usage.UsageManagerImpl$1.runInContext(UsageManagerImpl.java:369) ~[classes/:?]                                                                                       
        at org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49) ~[cloud-framework-managed-context-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]                                                                                                                                                                                           
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56) ~[cloud-framework-managed-context-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103) ~[cloud-framework-managed-context-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53) ~[cloud-framework-managed-context-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46) ~[cloud-framework-managed-context-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]
        at com.cloud.usage.UsageManagerImpl.run(UsageManagerImpl.java:371) ~[classes/:?]                                                                                                  
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]                                                                                                
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]                                                                                                               
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]                                                                                                                                                                                                                                                   
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]                                                                                                                                                                                                                                                                                  
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]                                                                                                                                                                                                                                                                                  
        at java.lang.Thread.run(Thread.java:829) ~[?:?]                                                                                                                                  
Caused by: java.sql.SQLException: No value specified for parameter 4                                                                                                                     
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                                                      
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                              
        at com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:555) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                                        
        at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:339) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                                      
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                               
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                               
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                                  
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994) ~[mysql-connector-j-8.0.33.jar:8.0.33]                                                                                                                                                                                                                                        
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) ~[HikariCP-5.1.0.jar:?]                                                                                                                                                                                                                                                     
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) ~[HikariCP-5.1.0.jar:?]                                                                                                                                                                                                                                            
        at com.cloud.usage.dao.UsageBackupDaoImpl.removeUsage(UsageBackupDaoImpl.java:72) ~[cloud-engine-schema-4.21.0.0-SNAPSHOT.jar:4.21.0.0-SNAPSHOT]             

After Fix:

  1. Created two backups for a vm (id=8) with a backup_offering (id=1)
    (Ignore usage_backup id 20 as it from a previous testing)
Screenshot 2025-08-27 at 10 37 00 AM 2. Deleted one backup Screenshot 2025-08-27 at 10 37 40 AM 3. Deleted another backup Screenshot 2025-08-27 at 10 37 58 AM 4. Removed backup offering Screenshot 2025-08-27 at 10 38 25 AM

How did you try to break this feature and the system with this change?

@abh1sar
Copy link
Collaborator Author

abh1sar commented Aug 27, 2025

@blueorangutan package

@blueorangutan
Copy link

@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.36%. Comparing base (f2d6356) to head (eef76c2).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...rg/apache/cloudstack/backup/BackupManagerImpl.java 50.00% 1 Missing and 1 partial ⚠️
...n/java/com/cloud/usage/dao/UsageBackupDaoImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #11522   +/-   ##
=========================================
  Coverage     17.35%   17.36%           
- Complexity    15230    15231    +1     
=========================================
  Files          5886     5886           
  Lines        525685   525683    -2     
  Branches      64159    64160    +1     
=========================================
+ Hits          91247    91260   +13     
+ Misses       424138   424122   -16     
- Partials      10300    10301    +1     
Flag Coverage Δ
uitests 3.63% <ø> (+<0.01%) ⬆️
unittests 18.40% <40.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14738

Copy link
Member

@winterhazel winterhazel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM. Did not test

@rohityadavcloud rohityadavcloud added this to the 4.22.0 milestone Aug 27, 2025
Copy link
Contributor

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

8 participants