Skip to content

Commit

Permalink
scheduler: check daily job limit on each job, not just when choosing AV
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpanderson committed Mar 29, 2019
1 parent 63d679c commit 816288f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sched/sched_send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ const char* find_user_friendly_name(int appid) {
return "deprecated application";
}

// Called at start of request handling.
// 1) if there's a global jobs/day limit, enforce it using HAV limit
// 2) if last RPC was yesterday or earlier, clear n_jobs_today for HAV
//
static void update_quota(DB_HOST_APP_VERSION& hav) {
if (config.daily_result_quota) {
if (hav.max_jobs_per_day == 0) {
Expand Down
9 changes: 9 additions & 0 deletions sched/sched_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ inline int scaled_max_jobs_per_day(DB_HOST_APP_VERSION& hav, HOST_USAGE& hu) {
return n;
}

// are we at the jobs/day limit for this (host, app version)?
// (if so don't use the app version)
//
inline bool daily_quota_exceeded(DB_ID_TYPE gavid, HOST_USAGE& hu) {
DB_HOST_APP_VERSION* havp = lookup_host_app_version(gavid);
if (!havp) return false;
Expand Down Expand Up @@ -668,6 +671,12 @@ BEST_APP_VERSION* get_app_version(
}
}

// do this check again since we might have sent a job w/ this AV
//
if (daily_quota_exceeded(bavp->avp->id, bavp->host_usage)) {
break;
}

if (config.debug_version_select) {
app_version_desc(*bavp, buf);
log_messages.printf(MSG_NORMAL,
Expand Down

0 comments on commit 816288f

Please sign in to comment.