Skip to content

Commit

Permalink
mysql: Fix 64bit ranges in job and group stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Aug 10, 2015
1 parent 22ef3dd commit 686237d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion mxq_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion mxq_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mxqdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 35 additions & 16 deletions mysql/create_tables
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 686237d

Please sign in to comment.