Skip to content

Make worker and API thread pool size configurable#13565

Open
Damans227 wants to merge 2 commits into
apache:4.22from
Damans227:pool-size-configurable-422
Open

Make worker and API thread pool size configurable#13565
Damans227 wants to merge 2 commits into
apache:4.22from
Damans227:pool-size-configurable-422

Conversation

@Damans227

Copy link
Copy Markdown
Collaborator

Description

The AsyncJobManager's API and Worker executor thread pool sizes are currently derived solely from db.cloud.maxActive (maxActive/2 and maxActive*2/3 respectively). This coupling doesn't account for environments with predominantly I/O-bound workers, where threads are held waiting on external responses for extended periods and higher pool sizes may be needed independently of the DB connection count.

This PR adds two global config keys:

  • api.job.pool.size (default: 50)
  • work.job.pool.size (default: 50)

The actual pool size is Math.max(configured value, db-derived default), preserving existing behavior by default while allowing operators to increase pool sizes when workloads require it. Pool sizes and their derivation are logged at startup for observability.

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

How Has This Been Tested?

Added unit tests in AsyncJobManagerImplTest that call configure() directly and assert on the real core pool size of the created executors (via reflection), covering both the "configured value wins" and "db-derived default wins" cases for both pools. Ran the full AsyncJobManagerImplTest suite locally (7 tests), all passing.

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

Verified the new config keys follow the existing ConfigKey pattern in this class (category, type, name, default, description, isDynamic, scope), and that isDynamic is correctly set to false since the executor pools are only created once at startup, so a dynamic config change wouldn't take effect without a restart anyway.

sachindoddaguni and others added 2 commits July 7, 2026 14:11
The AsyncJobManager's API and Worker executor thread pool sizes are
currently derived solely from db.cloud.maxActive (maxActive/2 and
maxActive*2/3 respectively). This coupling doesn't account for
environments with predominantly I/O-bound workers, where threads are
held waiting on external responses for extended periods and higher
pool sizes may be needed independently of the DB connection count.

This adds two global config keys:
- api.job.pool.size (default: 50)
- work.job.pool.size (default: 50)

The actual pool size is Math.max(configured value, db-derived
default), preserving existing behavior by default while allowing
operators to increase pool sizes when workloads require it. Pool
sizes and their derivation are logged at startup for observability.
…rtions

The previous unit tests for the api.job.pool.size/work.job.pool.size
config keys only re-ran Math.max() on local hardcoded values, or
checked ConfigKey plumbing directly, without ever calling
AsyncJobManagerImpl.configure() itself. That meant a regression in the
actual pool-sizing logic wouldn't have been caught.

These tests now invoke configure() directly and assert on the real
core pool size of the created _apiJobExecutor/_workerJobExecutor via
reflection, with @Before/@after hooks to stub db.properties and reset
config/executor state between tests.
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 17.67%. Comparing base (a951ac6) to head (5d500b8).

Files with missing lines Patch % Lines
...stack/framework/jobs/impl/AsyncJobManagerImpl.java 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #13565   +/-   ##
=========================================
  Coverage     17.67%   17.67%           
- Complexity    15797    15798    +1     
=========================================
  Files          5923     5923           
  Lines        533349   533355    +6     
  Branches      65248    65248           
=========================================
+ Hits          94253    94267   +14     
+ Misses       428437   428428    -9     
- Partials      10659    10660    +1     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.75% <90.90%> (+<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.

@nvazquez nvazquez added this to the 4.22.2 milestone Jul 7, 2026
@nvazquez

nvazquez commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez 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 18490

Integer.class, "vm.job.lock.timeout", "1800",
"Time in seconds to wait in acquiring lock to submit a vm worker job", false);
private static final ConfigKey<Boolean> HidePassword = new ConfigKey<Boolean>("Advanced", Boolean.class, "log.hide.password", "true", "If set to true, the password is hidden", true, ConfigKey.Scope.Global);
public static final ConfigKey<Integer> ApiJobPoolSize = new ConfigKey<>("Advanced", Integer.class, "api.job.pool.size", "50",

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.

I recall Vishesh had some changes in the past so that the pool size can be updated dynamically when the value is changed, no need to restart management server.
maybe @vishesh92 can give some advice

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.

6 participants