From c82f9b4470f91f3fa0c5dc543c09f8375177030b Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Fri, 26 Feb 2010 20:21:52 +0000 Subject: [PATCH] ok, ready for the merge --- RELEASE_NOTES | 6 +- src/common/parse_time.c | 1 - src/common/slurm_protocol_defs.c | 36 ++ src/common/slurm_protocol_defs.h | 2 + src/database/mysql_common.c | 31 +- .../mysql/accounting_storage_mysql.c | 8 +- .../accounting_storage/mysql/as_mysql_assoc.c | 2 +- .../mysql/as_mysql_convert.c | 5 +- .../mysql/as_mysql_rollup.c | 3 +- .../accounting_storage/mysql/as_mysql_usage.c | 318 +++++++++++++----- src/sacct/print.c | 12 +- 11 files changed, 315 insertions(+), 109 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 6a1f9db1650..c4f45157c3c 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -9,7 +9,11 @@ You will not need to update all clusters at the same time, but it is very important to update slurmdbd first and having it running before updating any other clusters making use of it. No real harm will come from updating your systems before the slurmdbd, but they will not talk to each other -until you do. +until you do. Also at least the first time running the slurmdbd you need to make sure your my.cfg file has innodb_buffer_pool_size equal to at least 64M. You can accomplish this by adding the line + +innodb_buffer_pool_size=64M + +under the [mysqld] reference and restarting the mysqld. This is needed when converting large tables over to the new database schema. SLURM can be upgraded from version 2.1 to version 2.2 without loss of jobs or other state. diff --git a/src/common/parse_time.c b/src/common/parse_time.c index 9033550b2b0..0d01ef96d59 100644 --- a/src/common/parse_time.c +++ b/src/common/parse_time.c @@ -651,7 +651,6 @@ extern void mins2time_str(uint32_t time, char *string, int size) minutes = time % 60; hours = time / 60 % 24; days = time / 1440; - if (days) snprintf(string, size, "%ld-%2.2ld:%2.2ld:%2.2ld", diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index fd98890b3a2..9bda2136778 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -121,6 +121,42 @@ extern void slurm_destroy_uint32_ptr(void *object) xfree(tmp); } +/* here to add \\ to all \" in a string this needs to be xfreed later */ +extern char *slurm_add_slash_to_quotes(char *str) +{ + int i=0, start=0; + char *fixed = NULL; + + if(!str) + return NULL; + + while(str[i]) { + if((str[i] == '"')) { + char *tmp = xstrndup(str+start, i-start); + xstrfmtcat(fixed, "%s\\\"", tmp); + xfree(tmp); + start = i+1; + } + + if((str[i] == '\'')) { + char *tmp = xstrndup(str+start, i-start); + xstrfmtcat(fixed, "%s\\\'", tmp); + xfree(tmp); + start = i+1; + } + + i++; + } + + if((i-start) > 0) { + char *tmp = xstrndup(str+start, i-start); + xstrcat(fixed, tmp); + xfree(tmp); + } + + return fixed; +} + /* returns number of objects added to list */ extern int slurm_addto_char_list(List char_list, char *names) { diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 0c43ec1f9d3..d801259ccb0 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -911,6 +911,8 @@ extern void slurm_msg_t_copy(slurm_msg_t *dest, slurm_msg_t *src); extern void slurm_destroy_char(void *object); extern void slurm_destroy_uint32_ptr(void *object); +/* here to add \\ to all \" in a string this needs to be xfreed later */ +extern char *slurm_add_slash_to_quotes(char *str); extern int slurm_addto_char_list(List char_list, char *names); extern int slurm_sort_char_list_asc(char *name_a, char *name_b); extern int slurm_sort_char_list_desc(char *name_a, char *name_b); diff --git a/src/database/mysql_common.c b/src/database/mysql_common.c index 42975cb6a9d..88b4a7d683b 100644 --- a/src/database/mysql_common.c +++ b/src/database/mysql_common.c @@ -147,6 +147,7 @@ static int _mysql_make_table_current(MYSQL *mysql_db, char *table_name, START_TIMER; while(fields[i].name) { int found = 0; + list_iterator_reset(itr); while((col = list_next(itr))) { if(!strcmp(col, fields[i].name)) { @@ -265,12 +266,14 @@ static int _mysql_make_table_current(MYSQL *mysql_db, char *table_name, /* see if we have already done this definition */ if(!adding) { + char *quoted = slurm_add_slash_to_quotes(query); char *query2 = xstrdup_printf("select table_name from " "%s where definition='%s'", - table_defs_table, query); + table_defs_table, quoted); MYSQL_RES *result = NULL; MYSQL_ROW row; + xfree(quoted); run_update = 1; if((result = mysql_db_query_ret(mysql_db, query2, 0))) { if((row = mysql_fetch_row(result))) @@ -278,28 +281,44 @@ static int _mysql_make_table_current(MYSQL *mysql_db, char *table_name, mysql_free_result(result); } xfree(query2); + if(run_update) { + run_update = 2; + query2 = xstrdup_printf("select table_name from " + "%s where table_name='%s'", + table_defs_table, table_name); + if((result = mysql_db_query_ret(mysql_db, query2, 0))) { + if((row = mysql_fetch_row(result))) + run_update = 1; + mysql_free_result(result); + } + xfree(query2); + } } /* if something has changed run the alter line */ if(run_update || adding) { time_t now = time(NULL); char *query2 = NULL; + char *quoted = NULL; - debug("Table %s has changed. Updating...", table_name); - + if(run_update == 2) + debug4("Table %s doesn't exist, adding", table_name); + else + debug("Table %s has changed. Updating...", table_name); if(mysql_db_query(mysql_db, query)) { xfree(query); return SLURM_ERROR; } - + quoted = slurm_add_slash_to_quotes(correct_query); query2 = xstrdup_printf("insert into %s (creation_time, " "mod_time, table_name, definition) " "values (%d, %d, '%s', '%s') " "on duplicate key update " "definition='%s', mod_time=%d;", table_defs_table, now, now, - table_name, correct_query, - correct_query, now); + table_name, quoted, + quoted, now); + xfree(quoted); if(mysql_db_query(mysql_db, query2)) { xfree(query2); return SLURM_ERROR; diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index 0cb036df7dc..ced159c1c96 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -494,12 +494,12 @@ static int _as_mysql_acct_check_tables(MYSQL *db_conn) slurm_mutex_unlock(&as_mysql_cluster_list_lock); if(rc != SLURM_SUCCESS) return rc; - DEF_TIMERS; - START_TIMER; + /* DEF_TIMERS; */ + /* START_TIMER; */ if(as_mysql_convert_tables(db_conn) != SLURM_SUCCESS) return SLURM_ERROR; - END_TIMER; - info("conversion took %s", TIME_STR); + /* END_TIMER; */ + /* info("conversion took %s", TIME_STR); */ if(mysql_db_create_table(db_conn, acct_coord_table, acct_coord_table_fields, diff --git a/src/plugins/accounting_storage/mysql/as_mysql_assoc.c b/src/plugins/accounting_storage/mysql/as_mysql_assoc.c index a58c891ab4c..3ed74f4728e 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_assoc.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_assoc.c @@ -2445,7 +2445,7 @@ extern List as_mysql_modify_assocs(mysql_conn_t *mysql_conn, uint32_t uid, xstrfmtcat(object, "t1.%s", massoc_req_inx[0]); for(i=1; i<MASSOC_COUNT; i++) - xstrfmtcat(object, "t1.%s", massoc_req_inx[i]); + xstrfmtcat(object, ", t1.%s", massoc_req_inx[i]); ret_list = list_create(slurm_destroy_char); diff --git a/src/plugins/accounting_storage/mysql/as_mysql_convert.c b/src/plugins/accounting_storage/mysql/as_mysql_convert.c index fab6780ac67..4c593010cf7 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_convert.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_convert.c @@ -520,7 +520,7 @@ end_it: verbose("Cluster %s updated", cluster_name); } else { verbose("Cluster %s update failed", cluster_name); - if(mysql_db_rollback(db_conn)) + if(db_conn && mysql_db_rollback(db_conn)) error("rollback failed"); } @@ -733,6 +733,9 @@ extern int as_mysql_convert_tables(MYSQL *db_conn) char *query = NULL; char *drop_query = NULL; int rc = SLURM_ERROR; + pthread_mutex_t rolledup_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_cond_t rolledup_cond; + /* now do associations */ query = xstrdup_printf("show tables like '%s';", assoc_table); diff --git a/src/plugins/accounting_storage/mysql/as_mysql_rollup.c b/src/plugins/accounting_storage/mysql/as_mysql_rollup.c index a4c68203984..78a59d4d781 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_rollup.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_rollup.c @@ -1108,7 +1108,8 @@ extern int as_mysql_monthly_rollup(mysql_conn_t *mysql_conn, /* info("start %s", ctime(&curr_start)); */ /* info("end %s", ctime(&curr_end)); */ query = xstrdup_printf( - "insert into \"%s_%s\" (creation_time, mod_time, id_assoc, " + "insert into \"%s_%s\" (creation_time, " + "mod_time, id_assoc, " "time_start, alloc_cpu_secs) select %d, %d, id_assoc, " "%d, @ASUM:=SUM(alloc_cpu_secs) from \"%s_%s\" where " "(time_start < %d && time_start >= %d) " diff --git a/src/plugins/accounting_storage/mysql/as_mysql_usage.c b/src/plugins/accounting_storage/mysql/as_mysql_usage.c index 2d73d163a70..f6b8fecbb24 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_usage.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_usage.c @@ -43,6 +43,111 @@ time_t global_last_rollup = 0; pthread_mutex_t rollup_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t usage_rollup_lock = PTHREAD_MUTEX_INITIALIZER; + +typedef struct { + uint16_t archive_data; + char *cluster_name; + time_t hour_start; + time_t hour_end; + time_t day_start; + time_t day_end; + time_t month_start; + time_t month_end; + mysql_conn_t *mysql_conn; + int *rc; + int *rolledup; + pthread_mutex_t *rolledup_lock; + pthread_cond_t *rolledup_cond; +} local_rollup_t; + +static void *_cluster_rollup_usage(void *arg) +{ + local_rollup_t *local_rollup = (local_rollup_t *)arg; + int rc = SLURM_SUCCESS; + char timer_str[128]; + mysql_conn_t mysql_conn; + DEF_TIMERS; + + memset(&mysql_conn, 0, sizeof(mysql_conn_t)); + mysql_conn.rollback = 1; + mysql_conn.conn = local_rollup->mysql_conn->conn; + + /* Each thread needs it's own connection we can't use the one + * sent from the parent thread. */ + rc = check_connection(&mysql_conn); + + if(rc != SLURM_SUCCESS) + goto end_it; + + if((local_rollup->hour_end - local_rollup->hour_start) > 0) { + START_TIMER; + rc = as_mysql_hourly_rollup(&mysql_conn, + local_rollup->cluster_name, + local_rollup->hour_start, + local_rollup->hour_end); + snprintf(timer_str, sizeof(timer_str), + "hourly_rollup for %s", local_rollup->cluster_name); + END_TIMER3(timer_str, 5000000); + if(rc != SLURM_SUCCESS) + goto end_it; + } + + if((local_rollup->day_end - local_rollup->day_start) > 0) { + START_TIMER; + rc = as_mysql_daily_rollup(&mysql_conn, + local_rollup->cluster_name, + local_rollup->day_start, + local_rollup->day_end, + local_rollup->archive_data); + snprintf(timer_str, sizeof(timer_str), + "daily_rollup for %s", local_rollup->cluster_name); + END_TIMER3(timer_str, 5000000); + if(rc != SLURM_SUCCESS) + goto end_it; + } + + if((local_rollup->month_end - local_rollup->month_start) > 0) { + START_TIMER; + rc = as_mysql_monthly_rollup(&mysql_conn, + local_rollup->cluster_name, + local_rollup->month_start, + local_rollup->month_end, + local_rollup->archive_data); + snprintf(timer_str, sizeof(timer_str), + "monthly_rollup for %s", local_rollup->cluster_name); + END_TIMER3(timer_str, 5000000); + if(rc != SLURM_SUCCESS) + goto end_it; + } + +end_it: + if(rc == SLURM_SUCCESS) { + if(mysql_db_commit(mysql_conn.db_conn)) { + error("Couldn't commit rollup of cluster %s", + local_rollup->cluster_name); + rc = SLURM_ERROR; + } + } else { + error("Cluster %s rollup failed", local_rollup->cluster_name); + if(mysql_conn.db_conn && mysql_db_rollback(mysql_conn.db_conn)) + error("rollback failed"); + } + + mysql_close_db_connection(&mysql_conn.db_conn); + + slurm_mutex_lock(local_rollup->rolledup_lock); + (*local_rollup->rolledup)++; + if((rc != SLURM_SUCCESS) && ((*local_rollup->rc) == SLURM_SUCCESS)) + (*local_rollup->rc) = rc; + pthread_cond_signal(local_rollup->rolledup_cond); + slurm_mutex_unlock(local_rollup->rolledup_lock); + xfree(local_rollup); + + return NULL; +} + + static int _get_cluster_usage(mysql_conn_t *mysql_conn, uid_t uid, acct_cluster_rec_t *cluster_rec, slurmdbd_msg_type_t type, @@ -495,7 +600,8 @@ is_user: switch (type) { case DBD_GET_ASSOC_USAGE: query = xstrdup_printf( - "select %s from \"%s_%s\" as t1, \"%s_%s\" as t2, \"%s_%s\" as t3 " + "select %s from \"%s_%s\" as t1, " + "\"%s_%s\" as t2, \"%s_%s\" as t3 " "where (t1.time_start < %d && t1.time_start >= %d) " "&& t1.id_assoc=t2.id_assoc && t3.id_assoc=%d && " "t2.lft between t3.lft and t3.rgt " @@ -548,7 +654,7 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, uint16_t archive_data) { int rc = SLURM_SUCCESS; - int i = 0; + int i = 0, rolledup = 0; time_t my_time = sent_end; struct tm start_tm; struct tm end_tm; @@ -559,10 +665,17 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, time_t last_hour = sent_start; time_t last_day = sent_start; time_t last_month = sent_start; - time_t start_time = 0; - time_t end_time = 0; + time_t hour_start; + time_t hour_end; + time_t day_start; + time_t day_end; + time_t month_start; + time_t month_end; + ListIterator itr; - DEF_TIMERS; + pthread_mutex_t rolledup_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_cond_t rolledup_cond; + //DEF_TIMERS; char *update_req_inx[] = { "hourly_rollup", @@ -695,7 +808,7 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, return SLURM_ERROR; } - /* below and anywhere in a rollup plugin when dealing with + /* Below and anywhere in a rollup plugin when dealing with * epoch times we need to set the tm_isdst = -1 so we don't * have to worry about the time changes. Not setting it to -1 * will cause problems in the day and month with the date change. @@ -704,88 +817,42 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, start_tm.tm_sec = 0; start_tm.tm_min = 0; start_tm.tm_isdst = -1; - start_time = mktime(&start_tm); + hour_start = mktime(&start_tm); + end_tm.tm_sec = 0; end_tm.tm_min = 0; end_tm.tm_isdst = -1; - end_time = mktime(&end_tm); + hour_end = mktime(&end_tm); -/* info("hour start %s", ctime(&start_time)); */ -/* info("hour end %s", ctime(&end_time)); */ -/* info("diff is %d", end_time-start_time); */ +/* info("hour start %s", ctime(&hour_start)); */ +/* info("hour end %s", ctime(&hour_end)); */ +/* info("diff is %d", hour_end-hour_start); */ slurm_mutex_lock(&rollup_lock); - global_last_rollup = end_time; + global_last_rollup = hour_end; slurm_mutex_unlock(&rollup_lock); - if(end_time-start_time > 0) { - START_TIMER; - slurm_mutex_lock(&as_mysql_cluster_list_lock); - itr = list_iterator_create(as_mysql_cluster_list); - while((tmp = list_next(itr))) { - if((rc = as_mysql_hourly_rollup(mysql_conn, tmp, - start_time, end_time)) - != SLURM_SUCCESS) - break; - } - list_iterator_destroy(itr); - slurm_mutex_unlock(&as_mysql_cluster_list_lock); - if(rc != SLURM_SUCCESS) - return rc; - END_TIMER3("hourly_rollup", 5000000); - /* If we have a sent_end do not update the last_run_table */ - if(!sent_end) - query = xstrdup_printf("update %s set hourly_rollup=%d", - last_ran_table, end_time); - } else { - debug2("no need to run this hour %d <= %d", - end_time, start_time); - } - + /* set up the day period */ if(!localtime_r(&last_day, &start_tm)) { error("Couldn't get localtime from day %d", last_day); return SLURM_ERROR; } + start_tm.tm_sec = 0; start_tm.tm_min = 0; start_tm.tm_hour = 0; start_tm.tm_isdst = -1; - start_time = mktime(&start_tm); + day_start = mktime(&start_tm); + end_tm.tm_hour = 0; end_tm.tm_isdst = -1; - end_time = mktime(&end_tm); - -/* info("day start %s", ctime(&start_time)); */ -/* info("day end %s", ctime(&end_time)); */ -/* info("diff is %d", end_time-start_time); */ - - if(end_time-start_time > 0) { - START_TIMER; - slurm_mutex_lock(&as_mysql_cluster_list_lock); - itr = list_iterator_create(as_mysql_cluster_list); - while((tmp = list_next(itr))) { - if((rc = as_mysql_daily_rollup(mysql_conn, tmp, - start_time, end_time, - archive_data)) - != SLURM_SUCCESS) - break; - } - list_iterator_destroy(itr); - slurm_mutex_unlock(&as_mysql_cluster_list_lock); - if(rc != SLURM_SUCCESS) - return rc; + day_end = mktime(&end_tm); - END_TIMER2("daily_rollup"); - if(query && !sent_end) - xstrfmtcat(query, ", daily_rollup=%d", end_time); - else if(!sent_end) - query = xstrdup_printf("update %s set daily_rollup=%d", - last_ran_table, end_time); - } else { - debug2("no need to run this day %d <= %d", - end_time, start_time); - } +/* info("day start %s", ctime(&day_start)); */ +/* info("day end %s", ctime(&day_end)); */ +/* info("diff is %d", day_end-day_start); */ + /* set up the month period */ if(!localtime_r(&last_month, &start_tm)) { error("Couldn't get localtime from month %d", last_month); return SLURM_ERROR; @@ -796,47 +863,108 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, start_tm.tm_hour = 0; start_tm.tm_mday = 1; start_tm.tm_isdst = -1; - start_time = mktime(&start_tm); - end_time = mktime(&end_tm); + month_start = mktime(&start_tm); end_tm.tm_sec = 0; end_tm.tm_min = 0; end_tm.tm_hour = 0; end_tm.tm_mday = 1; end_tm.tm_isdst = -1; - end_time = mktime(&end_tm); + month_end = mktime(&end_tm); + +/* info("month start %s", ctime(&month_start)); */ +/* info("month end %s", ctime(&month_end)); */ +/* info("diff is %d", month_end-month_start); */ + + slurm_mutex_lock(&usage_rollup_lock); + + slurm_mutex_init(&rolledup_lock); + pthread_cond_init(&rolledup_cond, NULL); + + //START_TIMER; + slurm_mutex_lock(&as_mysql_cluster_list_lock); + itr = list_iterator_create(as_mysql_cluster_list); + while((tmp = list_next(itr))) { + pthread_t rollup_tid; + pthread_attr_t rollup_attr; + local_rollup_t *local_rollup = xmalloc(sizeof(local_rollup_t)); + + local_rollup->archive_data = archive_data; + local_rollup->cluster_name = tmp; + + local_rollup->hour_start = hour_start; + local_rollup->hour_end = hour_end; + + local_rollup->day_start = day_start; + local_rollup->day_end = day_end; + + local_rollup->month_start = month_start; + local_rollup->month_end = month_end; + + local_rollup->mysql_conn = mysql_conn; + local_rollup->rc = &rc; + local_rollup->rolledup = &rolledup; + local_rollup->rolledup_lock = &rolledup_lock; + local_rollup->rolledup_cond = &rolledup_cond; + + slurm_attr_init(&rollup_attr); + /* _cluster_rollup_usage is responsible for freeing + this local_rollup */ + /* _cluster_rollup_usage(local_rollup); */ + if (pthread_create(&rollup_tid, &rollup_attr, + _cluster_rollup_usage, + (void *)local_rollup)) + fatal("pthread_create: %m"); + slurm_attr_destroy(&rollup_attr); + } + slurm_mutex_lock(&rolledup_lock); + list_iterator_destroy(itr); + slurm_mutex_unlock(&as_mysql_cluster_list_lock); -/* info("month start %s", ctime(&start_time)); */ -/* info("month end %s", ctime(&end_time)); */ -/* info("diff is %d", end_time-start_time); */ + while(rolledup < list_count(as_mysql_cluster_list)) { + pthread_cond_wait(&rolledup_cond, &rolledup_lock); + debug2("Got %d rolled up", rolledup); + } + slurm_mutex_unlock(&rolledup_lock); + debug2("Everything rolled up"); + slurm_mutex_destroy(&rolledup_lock); + pthread_cond_destroy(&rolledup_cond); + /* END_TIMER; */ + /* info("total time was %s", TIME_STR); */ - if(end_time-start_time > 0) { - START_TIMER; - slurm_mutex_lock(&as_mysql_cluster_list_lock); - itr = list_iterator_create(as_mysql_cluster_list); - while((tmp = list_next(itr))) { - if((rc = as_mysql_monthly_rollup( - mysql_conn, tmp, - start_time, end_time, archive_data)) - != SLURM_SUCCESS) - break; - } - list_iterator_destroy(itr); - slurm_mutex_unlock(&as_mysql_cluster_list_lock); - if(rc != SLURM_SUCCESS) - return rc; + if(rc != SLURM_SUCCESS) + goto end_it; + + if(hour_end-hour_start > 0) { + /* If we have a sent_end do not update the last_run_table */ + if(!sent_end) + query = xstrdup_printf("update %s set hourly_rollup=%d", + last_ran_table, hour_end); + } else + debug2("no need to run this hour %d <= %d", + hour_end, hour_start); - END_TIMER2("monthly_rollup"); + if(day_end-day_start > 0) { + if(query && !sent_end) + xstrfmtcat(query, ", daily_rollup=%d", day_end); + else if(!sent_end) + query = xstrdup_printf("update %s set daily_rollup=%d", + last_ran_table, day_end); + } else { + debug2("no need to run this day %d <= %d", + day_end, day_start); + } + if(month_end-month_start > 0) { if(query && !sent_end) - xstrfmtcat(query, ", monthly_rollup=%d", end_time); + xstrfmtcat(query, ", monthly_rollup=%d", month_end); else if(!sent_end) query = xstrdup_printf( "update %s set monthly_rollup=%d", - last_ran_table, end_time); + last_ran_table, month_end); } else { debug2("no need to run this month %d <= %d", - end_time, start_time); + month_end, month_start); } if(query) { @@ -845,5 +973,9 @@ extern int as_mysql_roll_usage(mysql_conn_t *mysql_conn, rc = mysql_db_query(mysql_conn->db_conn, query); xfree(query); } + +end_it: + slurm_mutex_unlock(&usage_rollup_lock); + return rc; } diff --git a/src/sacct/print.c b/src/sacct/print.c index dcc76f1794b..e062a83ebd1 100644 --- a/src/sacct/print.c +++ b/src/sacct/print.c @@ -50,7 +50,7 @@ char *_elapsed_time(long secs, long usecs) long subsec = 0; char *str = NULL; - if(secs < 0 || secs == NO_VAL) + if(secs < 0 || secs == (long)NO_VAL) return NULL; @@ -1143,6 +1143,16 @@ void print_fields(type_t type, void *object) case PRINT_TIMELIMIT: switch(type) { case JOB: + if (job->timelimit == INFINITE) + tmp_char = "UNLIMITED"; + else if (job->timelimit == NO_VAL) + tmp_char = "Partition_Limit"; + else if(job->timelimit) { + char tmp1[128]; + mins2time_str(job->timelimit, + tmp1, sizeof(tmp1)); + tmp_char = tmp1; + } break; case JOBSTEP: -- GitLab