Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (Core) Fixed calculateBackoffTime in JobQueueManagerAPIImpl #30350

Conversation

jgambarios
Copy link
Contributor

@jgambarios jgambarios commented Oct 15, 2024

This pull request introduces enhancements to the job queue management system to handle empty queue scenarios more effectively. The key changes include adding constants to cap and reset the empty queue count, refactoring the backoff time calculation, and adding tests for the new functionality.

Enhancements to job queue management:

Testing improvements:

This PR fixes: #30348

Introduced the calculateBackoffTime method to manage exponential backoff in job processing. Added corresponding unit tests and implemented a reset mechanism for the emptyQueueCount to improve reliability.
@jgambarios jgambarios enabled auto-merge October 15, 2024 16:17
@jgambarios jgambarios added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 9ea0573 Oct 15, 2024
35 checks passed
@jgambarios jgambarios deleted the issue-30348-Job-Queue-Negative-Timeout-Value-Causes-Error-in-logs branch October 15, 2024 18:21
spbolton pushed a commit that referenced this pull request Nov 11, 2024
This pull request introduces enhancements to the job queue management
system to handle empty queue scenarios more effectively. The key changes
include adding constants to cap and reset the empty queue count,
refactoring the backoff time calculation, and adding tests for the new
functionality.

Enhancements to job queue management:

*
[`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R117-R121):
Introduced `MAX_EMPTY_QUEUE_COUNT` and `EMPTY_QUEUE_RESET_THRESHOLD`
constants to cap and reset the empty queue count.
*
[`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L476-R485):
Refactored `processJobs` method to use `calculateBackoffTime` and
`incrementAndResetEmptyQueueCount` methods for better handling of empty
queue scenarios.
*
[`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R975-R1005):
Added `calculateBackoffTime` and `incrementAndResetEmptyQueueCount`
methods to encapsulate the logic for calculating backoff time and
resetting the empty queue count.

Testing improvements:

*
[`dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPITest.java`](diffhunk://#diff-93563af6a56c7a961561131bb9cb95c6ea24b9ba8508e3a98dc49d036ff78859R1293-R1312):
Added `test_calculateBackoffTime` method to verify the correctness of
the `calculateBackoffTime` method under various scenarios.
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.

Job Queue: Negative Timeout Value Causes Error in logs
3 participants