scheduler: fix bug that broke enforcement of per-app job limits

The old scheduler worked as follows:
    scan jobs; for each job
        get_app_version
        do various checks
        add_job_to_reply
The check for per-app job limits was in get_app_version,
and the incrementing of per-app job count is in add_job_to_reply.

The new (score-based) scheduler works as follows:
    scan jobs; for each job
        get_app_version
        add to list
    sort list by score
    scan list; for each job
        do various checks
        add_job_to_reply

So the limit check (in get_app_version) was ineffective
because it happens before we've incremented counts.

Fix: do the limit check (also) in the "scan list" loop.

Bigger picture: we need to restructure app version selection;
job limit enforcement doesn't belong there any more.
This commit is contained in:
David Anderson 2014-09-16 11:07:36 -07:00
parent 966b5d929c
commit 7a84dabbbc
1 changed files with 18 additions and 0 deletions

View File

@ -234,13 +234,31 @@ void send_work_score_type(int rt) {
bool sema_locked = false;
for (unsigned int i=0; i<jobs.size(); i++) {
// check limit on total jobs
//
if (!work_needed(false)) {
break;
}
// check limit on jobs for this processor type
//
if (!g_wreq->need_proc_type(rt)) {
break;
}
JOB& job = jobs[i];
// check limits on jobs for this (app, processor type)
//
if (config.max_jobs_in_progress.exceeded(job.app, job.bavp->host_usage.proc_type)) {
if (config.debug_quota) {
log_messages.printf(MSG_NORMAL,
"[quota] limit for app/proctype exceeded\n"
);
}
continue;
}
if (!sema_locked) {
lock_sema();
sema_locked = true;