fix: replace unmanaged thread creation with bounded ExecutorService in JobConfigurationServiceImpl#796
fix: replace unmanaged thread creation with bounded ExecutorService in JobConfigurationServiceImpl#796CodeBySayak wants to merge 2 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR fixes unmanaged thread proliferation in
JobConfigurationServiceImpl.javawhere rawnew Thread().start()calls were used to execute missed job triggers during application startup. Previously, each missed job spawned an unbounded unmanaged thread, which could lead to resource exhaustion when a large number of sync jobs were configured.Changes
ExecutorServiceusing:as a class-level field to manage lifecycle and concurrency of background tasks.
with:
to ensure thread creation is controlled and centrally managed.
Why is this needed?
On every application startup,
executeMissedTriggers()iterates over all active sync jobs and creates a new thread per missed trigger execution. The previous implementation had no upper bound on thread creation, which could result in:Using a fixed thread pool of size 5 ensures missed triggers are still processed concurrently while keeping concurrency within safe, bounded limits.
Impact
fixes #795