FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix for usage server getting stuck due to duplicate VM events by abh1sar · Pull Request #13019 · apache/cloudstack · GitHub

Repository navigation

Fix for usage server getting stuck due to duplicate VM events - #13019

Merged
winterhazel merged 3 commits into
apache:4.20from
shapeblue:usage-duplicate-vm
Jun 11, 2026
Merged

winterhazel merged 3 commits into
apache:4.20from
shapeblue:usage-duplicate-vm

Conversation

abh1sar commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes #12590

Fix is to remove the unique key constraint from the usage_vm_instance table.
The constraint is not required, and can cause issues with usage processing.
The other helper tables either don't have a constraint or duplicate events cannot happen as the event is generated only at create.
In case of VM instance the event is generated at every Start which makes it susceptible to duplicate events.

Added change in the upgrade path as well as in create-schema-premium.sql

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?

To test, I added 2 VM.START events to the usage_event table with the same created time (id 18 and 20) and set the usage.stats.job.aggregation.range to 5 (minutes)

Without the fix the usage server was stuck processing that interval

After removing the unique constraint, usage server finished successfully and generated the correct usage.

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

abh1sar added this to the 4.20.4 milestone Apr 14, 2026
abh1sar changed the title remove unique key constraint from cloud_usage.usage_vm_instance table Fix for usage server getting stuck due to duplicate VM events Apr 14, 2026
abh1sar requested a review from DaanHoogland April 14, 2026 09:47

codecov Bot commented Apr 14, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.73913% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.27%. Comparing base (8eb162c) to head (e5f59a3).
⚠️ Report is 11 commits behind head on 4.20.

Files with missing lines Patch % Lines
...ava/com/cloud/upgrade/dao/Upgrade42030to42040.java 18.18% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #13019   +/-   ##
=========================================
  Coverage     16.26%   16.27%           
- Complexity    13433    13439    +6     
=========================================
  Files          5665     5666    +1     
  Lines        500530   500557   +27     
  Branches      60787    60789    +2     
=========================================
+ Hits          81411    81444   +33     
+ Misses       410027   410009   -18     
- Partials       9092     9104   +12     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.12% <21.73%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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
Copy Markdown
Contributor

@blueorangutan package

Copy link
Copy Markdown

@sureshanaparti 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
Copy Markdown

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

DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@abh1sar I do not think this change is the best way to go. First an upgrade patch for minor version should be implicit, expecially if no actual changes are in the specific upgrade script. Second, the create schema script should be for 4.0 and all other changes should be entered in the upgrade scripts.

Copy link
Copy Markdown
Contributor

@abh1sar I do not think this change is the best way to go. First an upgrade patch for minor version should be implicit, expecially if no actual changes are in the specific upgrade script. Second, the create schema script should be for 4.0 and all other changes should be entered in the upgrade scripts.

cc @weizhouapache

Copy link
Copy Markdown
Contributor

@blueorangutan package

Copy link
Copy Markdown

@DaanHoogland 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
Copy Markdown

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

DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

we will have to make sure this happens for 22.1 and 23.0 as well.

Copy link
Copy Markdown
Contributor

@blueorangutan test

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copy link
Copy Markdown

[SF] Trillian test result (tid-15897)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 50830 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13019-t15897-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py

winterhazel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code looks good, needs upgrade testing

Copy link
Copy Markdown
Member

Tested the upgrade. It looks ok.

2026-06-11 15:13:56,404 DEBUG [c.c.u.d.Upgrade42030to42040] (main:[]) (logid:) Dropping index vm_instance_id from usage_vm_instance table if it exists
2026-06-11 15:13:56,501 DEBUG [c.c.u.d.DatabaseAccessObject] (main:[]) (logid:) Key vm_instance_id is dropped successfully from the table cloud_usage.usage_vm_instance

winterhazel merged commit 7bc458f into apache:4.20 Jun 11, 2026
25 of 26 checks passed

Copy link
Copy Markdown
Member

This one needs to be included in the 4.22.2 and 4.23.0 upgrade paths as well. I intend to include it while performing the merge forward.

DaanHoogland deleted the usage-duplicate-vm branch June 14, 2026 17:12
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 10, 2026
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate event for VM.START in the usage_event causes it to never get processed

5 participants


Back | FazBrowse Home | New Git URL