Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mxqkill'
* mxqkill:
  mxqkill: Set date_start and date_end to NOW() when cancelling jobs
  mxqkill: Fix error message
  mxqkill: Allow cancellation of assigned jobs
  mxq_job: Treat job_status KILLING as RUNNING
  • Loading branch information
mariux committed Aug 19, 2015
2 parents 7cd81b8 + 004f084 commit a911650
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions mxq_job.c
Expand Up @@ -486,7 +486,7 @@ int mxq_set_job_status_exited(struct mx_mysql *mysql, struct mxq_job *job)
return -1;
}

if (job->job_status != MXQ_JOB_STATUS_RUNNING) {
if (job->job_status != MXQ_JOB_STATUS_RUNNING && job->job_status != MXQ_JOB_STATUS_KILLING) {
mx_log_warning("new status==exited but old status(=%d) is != running ", job->job_status);
}

Expand All @@ -510,7 +510,7 @@ int mxq_set_job_status_exited(struct mx_mysql *mysql, struct mxq_job *job)
" stats_nvcsw = ?, "
" stats_nivcsw = ?"
" WHERE job_id = ?"
" AND job_status IN (" status_str(MXQ_JOB_STATUS_LOADED) ", " status_str(MXQ_JOB_STATUS_RUNNING) ")"
" AND job_status IN (" status_str(MXQ_JOB_STATUS_LOADED) ", " status_str(MXQ_JOB_STATUS_RUNNING) ", " status_str(MXQ_JOB_STATUS_KILLING) ")"
" AND host_hostname = ?"
" AND server_id = ?"
" AND host_pid = ?";
Expand Down Expand Up @@ -567,7 +567,7 @@ int mxq_set_job_status_unknown_for_server(struct mx_mysql *mysql, char *hostname
"UPDATE mxq_job SET"
" job_status = " status_str(MXQ_JOB_STATUS_UNKNOWN) ","
" date_end = NULL"
" WHERE job_status IN (" status_str(MXQ_JOB_STATUS_LOADED) "," status_str(MXQ_JOB_STATUS_RUNNING) ")"
" WHERE job_status IN (" status_str(MXQ_JOB_STATUS_LOADED) "," status_str(MXQ_JOB_STATUS_RUNNING) "," status_str(MXQ_JOB_STATUS_KILLING) ")"
" AND host_hostname = ?"
" AND server_id = ?";

Expand Down
6 changes: 3 additions & 3 deletions mxqkill.c
Expand Up @@ -133,7 +133,7 @@ static int update_job_status_cancelled_by_group(struct mx_mysql *mysql, struct m
"UPDATE mxq_job SET"
" job_status = " status_str(MXQ_JOB_STATUS_CANCELLED)
" WHERE group_id = ?"
" AND job_status = " status_str(MXQ_JOB_STATUS_INQ)
" AND job_status = IN (" status_str(MXQ_JOB_STATUS_INQ) "," status_str(MXQ_JOB_STATUS_ASSIGNED) ")"
" AND host_hostname = ''"
" AND server_id = ''"
" AND host_pid = 0"
Expand Down Expand Up @@ -180,7 +180,7 @@ static int update_job_status_cancelling_by_job_id_for_user(struct mx_mysql *mysq
" job_status = " status_str(MXQ_JOB_STATUS_CANCELLING)
" WHERE job_id = ?"
" AND user_uid = ?"
" AND job_status = " status_str(MXQ_JOB_STATUS_INQ)
" AND job_status IN (" status_str(MXQ_JOB_STATUS_INQ) "," status_str(MXQ_JOB_STATUS_ASSIGNED) ")"
" AND host_hostname = ''"
" AND server_id = ''"
" AND host_pid = 0"
Expand Down Expand Up @@ -450,7 +450,7 @@ int main(int argc, char *argv[])
mx_log_err("setting status of job %lu to CANCELLING failed: %s", arg_job_id, strerror(-res1));

if (res2 < 0)
mx_log_err("setting status of job %lu to CANCELLED failed: %s", arg_job_id, strerror(-res1));
mx_log_err("setting status of job %lu to CANCELLED failed: %s", arg_job_id, strerror(-res2));

if (res2 > 0) {
mx_log_notice("Job %lu cancelled!", arg_job_id);
Expand Down
4 changes: 3 additions & 1 deletion mysql/create_tables.sql
Expand Up @@ -214,7 +214,9 @@ CREATE TRIGGER mxq_update_job BEFORE UPDATE ON mxq_job
stats_total_real_sec=stats_total_real_sec+NEW.stats_real_sec,
group_mtime=NULL
WHERE group_id=NEW.group_id;
ELSEIF NEW.job_status = 990 AND OLD.job_status IN (0, 989) THEN
ELSEIF NEW.job_status = 990 AND OLD.job_status IN (0, 100, 989) THEN
SET NEW.date_start = NOW();
SET NEW.date_end = NEW.date_start;
UPDATE mxq_group SET
group_jobs_inq=group_jobs_inq-1,
group_jobs_cancelled=group_jobs_cancelled+1,
Expand Down
8 changes: 8 additions & 0 deletions mysql/fix_cancelled_job_dates.sql
@@ -0,0 +1,8 @@
UPDATE mxq_job
JOIN mxq_group
ON mxq_job.group_id = mxq_group.group_id
SET mxq_job.date_start = mxq_group.group_date_end,
mxq_job.date_end = mxq_group.group_date_end
WHERE job_status = 990
AND (date_start = 0 OR date_end = 0);

0 comments on commit a911650

Please sign in to comment.