From 125502303389a80d6011529f1b915000b67fdcee Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 8 Jan 2024 18:08:17 +0100 Subject: [PATCH] mxqkill: Correct job counts for cancelled groups Commit 22aadf3b87583 ("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`. --- mxqkill.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mxqkill.c b/mxqkill.c index 26cb79bb..b790af81 100644 --- a/mxqkill.c +++ b/mxqkill.c @@ -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());