Skip to content

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

Open
abh1sar wants to merge 2 commits intoapache:4.20from
shapeblue:usage-duplicate-vm
Open

Fix for usage server getting stuck due to duplicate VM events#13019
abh1sar wants to merge 2 commits intoapache:4.20from
shapeblue:usage-duplicate-vm

Conversation

@abh1sar
Copy link
Copy Markdown
Contributor

@abh1sar abh1sar commented Apr 14, 2026

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

Without the fix the usage server was stuck processing that interval
Screenshot 2026-04-14 at 10 44 21 AM

After removing the unique constraint, usage server finished successfully and generated the correct usage.
Screenshot 2026-04-14 at 10 52 26 AM

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

@abh1sar abh1sar added this to the 4.20.4 milestone Apr 14, 2026
@abh1sar 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 abh1sar requested a review from DaanHoogland April 14, 2026 09:47
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 21.73913% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (8eb162c) to head (37ffb5a).

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.26%           
- Complexity    13433    13435    +2     
=========================================
  Files          5665     5666    +1     
  Lines        500530   500553   +23     
  Branches      60787    60787           
=========================================
+ Hits          81411    81416    +5     
- Misses       410027   410046   +19     
+ Partials       9092     9091    -1     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.11% <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 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.

@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
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.

@blueorangutan
Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants