From 686237dda19faf8f6ea6460f73c6efa5c84105f3 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 10 Aug 2015 12:03:47 +0200 Subject: [PATCH] mysql: Fix 64bit ranges in job and group stats fixes https://github.molgen.mpg.de/mariux64/mxq/issues/18 --- mxq_group.c | 2 +- mxq_group.h | 2 +- mxqdump.c | 2 +- mysql/create_tables | 51 +++++++++++++++++++++++++++++++-------------- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/mxq_group.c b/mxq_group.c index 11546b9..48a4080 100644 --- a/mxq_group.c +++ b/mxq_group.c @@ -78,7 +78,7 @@ static int bind_result_group_fields(struct mx_mysql_bind *result, struct mxq_gro res += mx_mysql_bind_var(result, idx++, uint64, &(g->group_slots_running)); - res += mx_mysql_bind_var(result, idx++, uint32, &(g->stats_max_maxrss)); + res += mx_mysql_bind_var(result, idx++, uint64, &(g->stats_max_maxrss)); res += mx_mysql_bind_var(result, idx++, int64, &(g->stats_max_utime.tv_sec)); res += mx_mysql_bind_var(result, idx++, int64, &(g->stats_max_stime.tv_sec)); res += mx_mysql_bind_var(result, idx++, int64, &(g->stats_max_real.tv_sec)); diff --git a/mxq_group.h b/mxq_group.h index 577701b..4b13c64 100644 --- a/mxq_group.h +++ b/mxq_group.h @@ -43,7 +43,7 @@ struct mxq_group { uint64_t group_slots_running; - uint32_t stats_max_maxrss; + uint64_t stats_max_maxrss; struct timeval stats_max_utime; struct timeval stats_max_stime; diff --git a/mxqdump.c b/mxqdump.c index 424a279..3391a4c 100644 --- a/mxqdump.c +++ b/mxqdump.c @@ -111,7 +111,7 @@ static int print_group(struct mxq_group *g) " finished=%lu cancelled=%lu unknown=%lu inq=%lu" " job_threads=%u job_memory=%lukiB job_time=%us" " memory_load=%lu%% time_load=%lu%%" - " max_utime=%lu max_real=%lu max_memory=%ukiB job_command=%s group_name=%s\n", + " max_utime=%lu max_real=%lu max_memory=%lukiB job_command=%s group_name=%s\n", g->user_name, g->user_uid, g->group_id, g->group_priority, g->group_jobs, g->group_jobs_running, g->group_slots_running, g->group_jobs_failed, g->group_jobs_finished, g->group_jobs_cancelled, g->group_jobs_unknown, diff --git a/mysql/create_tables b/mysql/create_tables index 782d9fd..d0f4336 100644 --- a/mysql/create_tables +++ b/mysql/create_tables @@ -1,4 +1,24 @@ +ALTER TABLE mxq_job + MODIFY COLUMN stats_utime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_stime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_real_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_maxrss INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_minflt INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_majflt INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_nswap INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_inblock INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_oublock INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_nvcsw INT8 NOT NULL DEFAULT 0, + MODIFY COLUMN stats_nivcsw INT8 NOT NULL DEFAULT 0; + + +ALTER TABLE mxq_group + MODIFY COLUMN stats_max_maxrss INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_max_utime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_max_stime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + MODIFY COLUMN stats_max_real_sec INT8 UNSIGNED NOT NULL DEFAULT 0; + UPDATE mxq_group SET group_date_end=group_mtime WHERE group_date_end = 0 @@ -105,11 +125,10 @@ CREATE TABLE IF NOT EXISTS mxq_group ( group_date_end TIMESTAMP NOT NULL DEFAULT 0, - stats_max_maxrss INT4 NOT NULL DEFAULT 0, - - stats_max_utime_sec INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_max_stime_sec INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_max_real_sec INT4 UNSIGNED NOT NULL DEFAULT 0, + stats_max_maxrss INT8 UNSIGNED NOT NULL DEFAULT 0, + stats_max_utime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + stats_max_stime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, + stats_max_real_sec INT8 UNSIGNED NOT NULL DEFAULT 0, stats_total_utime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, stats_total_stime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, @@ -165,21 +184,21 @@ CREATE TABLE IF NOT EXISTS mxq_job ( stats_status INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_utime_sec INT4 UNSIGNED NOT NULL DEFAULT 0, + stats_utime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, stats_utime_usec INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_stime_sec INT4 UNSIGNED NOT NULL DEFAULT 0, + stats_stime_sec INT8 UNSIGNED NOT NULL DEFAULT 0, stats_stime_usec INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_real_sec INT4 UNSIGNED NOT NULL DEFAULT 0, + stats_real_sec INT8 UNSIGNED NOT NULL DEFAULT 0, stats_real_usec INT4 UNSIGNED NOT NULL DEFAULT 0, - stats_maxrss INT4 NOT NULL DEFAULT 0, - stats_minflt INT4 NOT NULL DEFAULT 0, - stats_majflt INT4 NOT NULL DEFAULT 0, - stats_nswap INT4 NOT NULL DEFAULT 0, - stats_inblock INT4 NOT NULL DEFAULT 0, - stats_oublock INT4 NOT NULL DEFAULT 0, - stats_nvcsw INT4 NOT NULL DEFAULT 0, - stats_nivcsw INT4 NOT NULL DEFAULT 0, + stats_maxrss INT8 NOT NULL DEFAULT 0, + stats_minflt INT8 NOT NULL DEFAULT 0, + stats_majflt INT8 NOT NULL DEFAULT 0, + stats_nswap INT8 NOT NULL DEFAULT 0, + stats_inblock INT8 NOT NULL DEFAULT 0, + stats_oublock INT8 NOT NULL DEFAULT 0, + stats_nvcsw INT8 NOT NULL DEFAULT 0, + stats_nivcsw INT8 NOT NULL DEFAULT 0, INDEX (job_id), INDEX (group_id),