Skip to content

Remove DB calls from VirtualMachinePowerStateSyncImpl logs - #14940

Open
nvazquez wants to merge 2 commits into
apache:mainfrom
shapeblue:424-remove-db-calls-powersync
Open

nvazquez wants to merge 2 commits into
apache:mainfrom
shapeblue:424-remove-db-calls-powersync

Conversation

@nvazquez

@nvazquez nvazquez commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses the following problem:

VirtualMachinePowerStateSyncImpl maintained a lazy cache of host id->host and vm id->vm mappings in order to provide host and vm objects in method debug/trace logs. On a cache miss, debug logs would use HostDao and VMInstanceDao to query the respective objects from the primary database. If all HikariCP DB connections were exhausted, this call would spin for 30 seconds before timing out and throwing a CloudRuntimeException. This meant that simple logging blocked agent-handler threads, creating performance degradation for the entire management server.

This PR fixes by logging just host ID and VM ID instead of objects, removing the need to call the primary DB and maintain a cache

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?

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

Maximilian Dittgen and others added 2 commits December 2, 2026 00:16
VirtualMachinePowerStateSyncImpl maintained a lazy cache of host
id->host and vm id->vm mappings in order to provide host and vm
objects in method debug/trace logs. On a cache miss, debug logs
would use HostDao and VMInstanceDao to query the respective objects
from the primary database. If all HikariCP DB connections were
exhausted, this call would spin for 30 seconds before timing out
and throwing a CloudRuntimeException. This meant that simple
logging blocked agent-handler threads, creating performance
degradation for the entire management server.

Fix by logging just host ID and VM ID instead of objects, removing
the need to call the primary DB and maintain a cache. Remove
corresponding imports, constructors, helper methods, and test
scaffold.
@nvazquez

nvazquez commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

Copilot AI 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.

🟢 Approval recommended

There are no active review issues for the change removing logging-only database lookups.

No open issues 🎉

What changed in this PR

Removes database lookups used only for VM power-state logging, preventing those logs from blocking agent-handler threads when database connections are exhausted.

Changes:

  • Logs host and VM IDs instead of loading objects through caches.
  • Removes logging-only caches, lookup helpers, and the HostDao dependency.
  • Removes obsolete test mocks and setup.
File Description
engine/​orchestration/​src/​test/​java/​com/​cloud/​vm/​VirtualMachinePowerStateSyncImplTest.java Removes setup and mocks for deleted logging lookups.
engine/​orchestration/​src/​main/​java/​com/​cloud/​vm/​VirtualMachinePowerStateSyncImpl.java Replaces cached object logging with IDs and removes lookup infrastructure.

Review effort: Balanced

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.08%. Comparing base (8eaff97) to head (371a1e0).

Files with missing lines Patch % Lines
...com/cloud/vm/VirtualMachinePowerStateSyncImpl.java 30.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main   #14940       +/-   ##
============================================
+ Coverage     3.86%   21.08%   +17.22%     
- Complexity       0    21284    +21284     
============================================
  Files          494     6058     +5564     
  Lines        42890   549881   +506991     
  Branches      8142    73538    +65396     
============================================
+ Hits          1657   115934   +114277     
- Misses       41001   420320   +379319     
- Partials       232    13627    +13395     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.54% <30.00%> (?)

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.

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

thanks @nvazquez, dropping the lookups from the logs looks right. CLGTM.

@DaanHoogland

Copy link
Copy Markdown
Contributor

not sure about testing, I think we cannot do more than smoke tests on this.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

This branch has not been deployed

No deployments
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.

5 participants