From 6af6b68f3b72f06b21c3809c3e2c4255aaa331cb Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 9 Feb 2009 23:27:13 +0000
Subject: [PATCH] fixed ending a reservation

---
 .../accounting_storage/mysql/accounting_storage_mysql.c  | 9 ++++++---
 src/plugins/accounting_storage/mysql/mysql_rollup.c      | 5 +++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
index 692e1cef6c9..8e5c5b23976 100644
--- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
+++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
@@ -7165,11 +7165,14 @@ extern int acct_storage_p_remove_reservation(mysql_conn_t *mysql_conn,
 			       resv_table, resv->time_start_prev,
 			       resv->id, 
 			       resv->time_start, resv->cluster);
-	/* then update the remaining ones with a deleted flag */
+	/* then update the remaining ones with a deleted flag and end
+	 * time of the time_start_prev which is set to when the
+	 * command was issued */
 	xstrfmtcat(query,
-		   "update %s set deleted=1 where deleted=0 and "
+		   "update %s set end=%d, deleted=1 where deleted=0 and "
 		   "id=%u and start=%d and cluster='%s;'",
-		   resv_table, resv->id, resv->time_start,
+		   resv_table, resv->time_start_prev,
+		   resv->id, resv->time_start,
 		   resv->cluster);
 	
 	debug3("%d(%d) query\n%s",
diff --git a/src/plugins/accounting_storage/mysql/mysql_rollup.c b/src/plugins/accounting_storage/mysql/mysql_rollup.c
index 85dc8cb711b..15aa4f062ec 100644
--- a/src/plugins/accounting_storage/mysql/mysql_rollup.c
+++ b/src/plugins/accounting_storage/mysql/mysql_rollup.c
@@ -650,7 +650,7 @@ extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn,
 				}				
 			}
 			c_usage->a_cpu += idle;
-			info("adding this much %d to cluster %s",
+			info("adding this much %lld to cluster %s",
 			     idle, c_usage->name);
 			/* now divide that time by the number of
 			   associations in the reservation and add
@@ -694,7 +694,8 @@ extern int mysql_hourly_rollup(mysql_conn_t *mysql_conn,
 			 * idle/reserved time put extra in the over
 			 * commit field
 			 */
-			
+/* 			info("%s got idle of %lld", c_usage->name,  */
+/* 			     (int64_t)c_usage->i_cpu); */
 			if((int64_t)c_usage->i_cpu < 0) {
 /* 				info("got %d %d %d", c_usage->r_cpu, */
 /* 				     c_usage->i_cpu, c_usage->o_cpu); */
-- 
GitLab