Skip to content

Commit f5ce25c

Browse files
committed
Job Concurrency: Fix issue where jobs stuck in "starting" state could cause queue limits to be bypassed.
1 parent 9696a40 commit f5ce25c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/job.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,13 @@ class Jobs {
688688
var job_limit = Tools.findObject( job.limits, { type: 'job', enabled: true } );
689689

690690
if (job_limit && job_limit.amount) {
691-
var jobs = this.findSimilarJobs(job, { state: 'active' });
691+
// include jobs in "starting" state so concurrent start actions can't bypass limits
692+
var jobs = this.findSimilarJobs(job, { state: 'active' }).concat(
693+
this.findSimilarJobs(job, { state: 'starting' })
694+
);
692695

693696
if (jobs.length >= job_limit.amount) {
694-
// job limit reached -- can we queue?
697+
// concurrent job limit reached -- can we queue?
695698
var queue_limit = Tools.findObject( job.limits, { type: 'queue', enabled: true } );
696699

697700
if (queue_limit && queue_limit.amount) {

0 commit comments

Comments
 (0)