Add GenericEnqueuer for consistent job priorities #4237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some delayed jobs enqueue other delayed jobs. For example, an app delete job may enqueue secondary jobs like blobstore deletion and buildpack cache cleanup.
If CAPI is configured with dedicated job priorities or dynamic job priorities is enabled, these secondary jobs might unintentionally receive a higher priority than their primary job. This could lead to less critical jobs, like blobstore deletion, being processed before more critical ones, such as service instance creation.
This change introduces
GenericEnqueuer
, a singleton enqueuer ensuring that all jobs enqueued within the same job execution context inherit the same priority.It is automatically initialized and destroyed within the CCJob wrapper, ensuring consistent priority propagation. Jobs can now be enqueued using:
GenericEnqueuer.shared.enqueue(job)
enqueue
andenqueue_pollable
now support an optionalpriority_increment
parameter.preserve_priority
flag ensures that re-enqueued jobs retain their previous priority.priority_increment
, ensuring correct propagation.100
nil
200
50
nil
50
nil
nil
50
20
10
(ignored)30
nil
50
20
(ignored)100
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests