Skip to content

Commit

Permalink
mxqkill: Correct job counts for cancelled groups
Browse files Browse the repository at this point in the history
Commit 22aadf3 ("sql: Implement mx_update_job2 trigger")
eliminated the `INQ`->`CANCELLED` housekeeping trigger, claiming that
the job state is no longer set to `CANCELLED` by code.

This is incorrect, as update_job_status_cancelled_by_group() still sets
the job status to `CANCELLED` when a group is cancelled.

Modify update_job_status_cancelled_by_group() to set the `job_cancelled`
flag instead of the `job_status`. Leave the job status transition to the
trigger.

Exclude `ASSIGNED` jobs, as the daemon handles them. Also, remove
unnecessary checks for unset `host_hostname`, `server_id`, and
`host_pid`.
  • Loading branch information
donald committed Jan 8, 2024
1 parent 9dda809 commit 1255023
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions mxqkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,9 @@ static int update_job_status_cancelled_by_group(struct mx_mysql *mysql, struct m
assert(g->group_id);

stmt = mx_mysql_statement_prepare(mysql,
"UPDATE mxq_job SET"
" job_status = " status_str(MXQ_JOB_STATUS_CANCELLED)
" WHERE group_id = ?"
" 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"
"UPDATE mxq_job SET job_cancelled = TRUE"
" WHERE group_id = ?"
" AND job_status = " status_str(MXQ_JOB_STATUS_INQ)
);
if (!stmt) {
mx_log_err("mx_mysql_statement_prepare(): %s", mx_mysql_error());
Expand Down

0 comments on commit 1255023

Please sign in to comment.