Skip to content

Fix concurrent publish bottleneck and agent ping task leaks - #14171

Draft
sb-abhish3k wants to merge 1 commit into
apache:4.20from
shapeblue:improve-messagebu-agentping
Draft

sb-abhish3k wants to merge 1 commit into
apache:4.20from
shapeblue:improve-messagebu-agentping

Conversation

@sb-abhish3k

Copy link
Copy Markdown

Description

MessageBusBase: replaced exclusive Gate with ReadWriteLock so multiple publishers can run in parallel. Subscriber callbacks are now invoked outside the lock to prevent slow hypervisor callbacks from starving write lock holders (subscribe/unsubscribe). Under heavy reconnect load (pod restart with many hosts) the old design serialized all publish() callers through a single gate, blocking API threads and causing full management server unresponsiveness.

DirectAgentAttache: fixed a race where PingTask could be scheduled after disconnect() had already cleared _futures, causing it to never be cancelled. Switched PingTask scheduling from scheduleAtFixedRate to scheduleWithFixedDelay so slow hypervisor responses do not pile up concurrent ping executions and exhaust the cron thread pool.

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?

MessageBusBase: replaced exclusive Gate with ReadWriteLock so multiple publishers can run in parallel.
Subscriber callbacks are now invoked outside the lock to prevent slow hypervisor callbacks from starving write lock holders (subscribe/unsubscribe).
Under heavy reconnect load (pod restart with many hosts) the old design serialized all publish() callers through a single gate, blocking API threads and causing full management server unresponsiveness.

DirectAgentAttache: fixed a race where PingTask could be scheduled after disconnect() had already cleared _futures, causing it to never be cancelled.
Switched PingTask scheduling from scheduleAtFixedRate to scheduleWithFixedDelay so slow hypervisor responses do not pile up concurrent ping executions and exhaust the cron thread pool.
@sb-abhish3k

Copy link
Copy Markdown
Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sb-abhish3k 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.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.87912% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.39%. Comparing base (8261bec) to head (ba53cba).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
...loudstack/framework/messagebus/MessageBusBase.java 0.00% 42 Missing ⚠️
...va/com/cloud/agent/manager/DirectAgentAttache.java 38.77% 26 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #14171      +/-   ##
============================================
+ Coverage     16.38%   16.39%   +0.01%     
- Complexity    13615    13622       +7     
============================================
  Files          5669     5669              
  Lines        501561   501471      -90     
  Branches      60922    60906      -16     
============================================
+ Hits          82168    82209      +41     
+ Misses       410185   410050     -135     
- Partials       9208     9212       +4     
Flag Coverage Δ
uitests 4.16% <ø> (+<0.01%) ⬆️
unittests 17.25% <20.87%> (+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.

@blueorangutan

Copy link
Copy Markdown

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

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.

3 participants