From 6e365dc913f15182314e6d497ceb5c436028d536 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Thu, 30 Apr 2009 23:15:55 +0000 Subject: [PATCH] fixed issues with updating a reservation with no new data. --- .../mysql/accounting_storage_mysql.c | 15 ++++++++------- src/slurmctld/reservation.c | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index ace9528a80e..c9556492460 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -6155,12 +6155,17 @@ extern int acct_storage_p_modify_reservation(mysql_conn_t *mysql_conn, xstrcat(cols, resv_req_inx[i]); } + /* check for both the last start and the start because most + likely the start time hasn't changed, but something else + may have since the last time we did an update to the + reservation. */ query = xstrdup_printf("select %s from %s where id=%u " - "and start=%d and cluster='%s' " + "and (start=%d || start=%d) and cluster='%s' " "and deleted=0 order by start desc " "limit 1 FOR UPDATE;", cols, resv_table, resv->id, - resv->time_start_prev, resv->cluster); + resv->time_start, resv->time_start_prev, + resv->cluster); try_again: debug4("%d(%d) query\n%s", mysql_conn->conn, __LINE__, query); @@ -6239,12 +6244,12 @@ try_again: mysql_free_result(result); + _setup_resv_limits(resv, &cols, &vals, &extra); /* use start below instead of resv->time_start_prev * just incase we have a different one from being out * of sync */ if((start > now) || !set) { - _setup_resv_limits(resv, &cols, &vals, &extra); /* we haven't started the reservation yet, or we are changing the associations or end time which we can just update it */ @@ -6255,10 +6260,6 @@ try_again: start, resv->cluster); } else { - /* since we change the start time here to now we can't - run the setup before here */ -/* resv->time_start = now; */ - _setup_resv_limits(resv, &cols, &vals, &extra); /* time_start is already done above and we * changed something that is in need on a new * entry. */ diff --git a/src/slurmctld/reservation.c b/src/slurmctld/reservation.c index 6629eb3c1ac..5f2dc214367 100644 --- a/src/slurmctld/reservation.c +++ b/src/slurmctld/reservation.c @@ -142,6 +142,7 @@ static slurmctld_resv_t *_copy_resv(slurmctld_resv_t *resv_orig_ptr) resv_copy_ptr->account_list[i] = xstrdup(resv_orig_ptr->account_list[i]); } + resv_copy_ptr->assoc_list = xstrdup(resv_orig_ptr->assoc_list); resv_copy_ptr->cpu_cnt = resv_orig_ptr->cpu_cnt; resv_copy_ptr->end_time = resv_orig_ptr->end_time; resv_copy_ptr->features = xstrdup(resv_orig_ptr->features); @@ -367,10 +368,11 @@ static int _set_assoc_list(slurmctld_resv_t *resv_ptr) if(resv_ptr->user_cnt) { for(i=0; i < resv_ptr->user_cnt; i++) { - assoc.uid = (uint32_t)resv_ptr->user_list[i]; - if(resv_ptr->account_cnt) { for(j=0; j < resv_ptr->account_cnt; j++) { + memset(&assoc, 0, + sizeof(acct_association_rec_t)); + assoc.uid = resv_ptr->user_list[i]; assoc.acct = resv_ptr->account_list[j]; if((rc = _append_assoc_list( assoc_list, &assoc)) @@ -379,6 +381,9 @@ static int _set_assoc_list(slurmctld_resv_t *resv_ptr) } } } else { + memset(&assoc, 0, + sizeof(acct_association_rec_t)); + assoc.uid = resv_ptr->user_list[i]; if((rc = assoc_mgr_get_user_assocs( acct_db_conn, &assoc, accounting_enforce, assoc_list)) @@ -389,8 +394,10 @@ static int _set_assoc_list(slurmctld_resv_t *resv_ptr) } } } else if(resv_ptr->account_cnt) { - assoc.uid = (uint32_t)NO_VAL; for(i=0; i < resv_ptr->account_cnt; i++) { + memset(&assoc, 0, + sizeof(acct_association_rec_t)); + assoc.uid = (uint32_t)NO_VAL; assoc.acct = resv_ptr->account_list[j]; if((rc = _append_assoc_list(assoc_list, &assoc)) != SLURM_SUCCESS) { @@ -496,7 +503,7 @@ static int _post_resv_update(slurmctld_resv_t *resv_ptr, if(strcmp(old_resv_ptr->assoc_list, resv_ptr->assoc_list)) resv.assocs = resv_ptr->assoc_list; - } else if(resv_ptr->assoc_list) + } else if(resv_ptr->assoc_list) resv.assocs = resv_ptr->assoc_list; if(old_resv_ptr->cpu_cnt != resv_ptr->cpu_cnt) @@ -2412,7 +2419,7 @@ extern void fini_job_resv_check(void) resv_ptr->start_time_prev = resv_ptr->start_time; resv_ptr->start_time_first = resv_ptr->start_time; resv_ptr->end_time += 24 * 60 * 60; - _post_resv_update(resv_ptr, NULL); + _post_resv_create(resv_ptr); last_resv_update = now; schedule_resv_save(); continue; @@ -2425,7 +2432,7 @@ extern void fini_job_resv_check(void) resv_ptr->start_time_prev = resv_ptr->start_time; resv_ptr->start_time_first = resv_ptr->start_time; resv_ptr->end_time += 7 * 24 * 60 * 60; - _post_resv_update(resv_ptr, NULL); + _post_resv_create(resv_ptr); last_resv_update = now; schedule_resv_save(); continue; -- GitLab