mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 04:49:05 +01:00
Add migration for job table contraints
This commit is contained in:
parent
2de85b0120
commit
8b6a1c8045
@ -4,7 +4,6 @@ CREATE TABLE IF NOT EXISTS job (
|
|||||||
cluster VARCHAR(255) NOT NULL,
|
cluster VARCHAR(255) NOT NULL,
|
||||||
subcluster VARCHAR(255) NOT NULL,
|
subcluster VARCHAR(255) NOT NULL,
|
||||||
start_time BIGINT NOT NULL, -- Unix timestamp
|
start_time BIGINT NOT NULL, -- Unix timestamp
|
||||||
|
|
||||||
user VARCHAR(255) NOT NULL,
|
user VARCHAR(255) NOT NULL,
|
||||||
project VARCHAR(255) NOT NULL,
|
project VARCHAR(255) NOT NULL,
|
||||||
partition VARCHAR(255),
|
partition VARCHAR(255),
|
||||||
@ -12,18 +11,15 @@ CREATE TABLE IF NOT EXISTS job (
|
|||||||
duration INT NOT NULL,
|
duration INT NOT NULL,
|
||||||
walltime INT NOT NULL,
|
walltime INT NOT NULL,
|
||||||
job_state VARCHAR(255) NOT NULL
|
job_state VARCHAR(255) NOT NULL
|
||||||
CHECK(job_state IN ('running', 'completed', 'failed', 'cancelled',
|
CHECK(job_state IN ('running', 'completed', 'failed', 'canceled', 'stopped', 'timeout')),
|
||||||
'stopped', 'timeout', 'preempted', 'out_of_memory')),
|
|
||||||
meta_data TEXT, -- JSON
|
meta_data TEXT, -- JSON
|
||||||
resources TEXT NOT NULL, -- JSON
|
resources TEXT NOT NULL, -- JSON
|
||||||
|
|
||||||
num_nodes INT NOT NULL,
|
num_nodes INT NOT NULL,
|
||||||
num_hwthreads INT,
|
num_hwthreads INT,
|
||||||
num_acc INT,
|
num_acc INT,
|
||||||
smt TINYINT NOT NULL DEFAULT 1 CHECK(smt IN (0, 1 )),
|
smt TINYINT NOT NULL DEFAULT 1 CHECK(smt IN (0, 1 )),
|
||||||
exclusive TINYINT NOT NULL DEFAULT 1 CHECK(exclusive IN (0, 1, 2)),
|
exclusive TINYINT NOT NULL DEFAULT 1 CHECK(exclusive IN (0, 1, 2)),
|
||||||
monitoring_status TINYINT NOT NULL DEFAULT 1 CHECK(monitoring_status IN (0, 1, 2, 3)),
|
monitoring_status TINYINT NOT NULL DEFAULT 1 CHECK(monitoring_status IN (0, 1, 2, 3)),
|
||||||
|
|
||||||
mem_used_max REAL NOT NULL DEFAULT 0.0,
|
mem_used_max REAL NOT NULL DEFAULT 0.0,
|
||||||
flops_any_avg REAL NOT NULL DEFAULT 0.0,
|
flops_any_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
mem_bw_avg REAL NOT NULL DEFAULT 0.0,
|
mem_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
@ -31,9 +27,7 @@ CREATE TABLE IF NOT EXISTS job (
|
|||||||
net_bw_avg REAL NOT NULL DEFAULT 0.0,
|
net_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
net_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
net_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
||||||
file_bw_avg REAL NOT NULL DEFAULT 0.0,
|
file_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
file_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
file_data_vol_total REAL NOT NULL DEFAULT 0.0;
|
||||||
UNIQUE (job_id, cluster, start_time)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS tag (
|
CREATE TABLE IF NOT EXISTS tag (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS job_new (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
job_id BIGINT NOT NULL,
|
||||||
|
cluster VARCHAR(255) NOT NULL,
|
||||||
|
subcluster VARCHAR(255) NOT NULL,
|
||||||
|
start_time BIGINT NOT NULL, -- Unix timestamp
|
||||||
|
user VARCHAR(255) NOT NULL,
|
||||||
|
project VARCHAR(255) NOT NULL,
|
||||||
|
partition VARCHAR(255),
|
||||||
|
array_job_id BIGINT,
|
||||||
|
duration INT NOT NULL,
|
||||||
|
walltime INT NOT NULL,
|
||||||
|
job_state VARCHAR(255) NOT NULL
|
||||||
|
CHECK(job_state IN ('running', 'completed', 'failed', 'canceled', 'stopped', 'timeout')),
|
||||||
|
meta_data TEXT, -- JSON
|
||||||
|
resources TEXT NOT NULL, -- JSON
|
||||||
|
num_nodes INT NOT NULL,
|
||||||
|
num_hwthreads INT,
|
||||||
|
num_acc INT,
|
||||||
|
smt TINYINT NOT NULL DEFAULT 1 CHECK(smt IN (0, 1 )),
|
||||||
|
exclusive TINYINT NOT NULL DEFAULT 1 CHECK(exclusive IN (0, 1, 2)),
|
||||||
|
monitoring_status TINYINT NOT NULL DEFAULT 1 CHECK(monitoring_status IN (0, 1, 2, 3)),
|
||||||
|
mem_used_max REAL NOT NULL DEFAULT 0.0,
|
||||||
|
flops_any_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
mem_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
load_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
net_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
net_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
||||||
|
file_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
file_data_vol_total REAL NOT NULL DEFAULT 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO job_new SELECT * FROM job;
|
||||||
|
DROP TABLE job;
|
||||||
|
ALTER TABLE job_new RENAME TO job;
|
||||||
|
VACUUM;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id, cluster, start_time);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list ON job (cluster, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_user ON job (user, cluster, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_users ON job (user, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_users_start ON job (start_time, user, job_state);
|
@ -0,0 +1,45 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS job_new (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
job_id BIGINT NOT NULL,
|
||||||
|
cluster VARCHAR(255) NOT NULL,
|
||||||
|
subcluster VARCHAR(255) NOT NULL,
|
||||||
|
start_time BIGINT NOT NULL, -- Unix timestamp
|
||||||
|
user VARCHAR(255) NOT NULL,
|
||||||
|
project VARCHAR(255) NOT NULL,
|
||||||
|
partition VARCHAR(255),
|
||||||
|
array_job_id BIGINT,
|
||||||
|
duration INT NOT NULL,
|
||||||
|
walltime INT NOT NULL,
|
||||||
|
job_state VARCHAR(255) NOT NULL
|
||||||
|
CHECK(job_state IN ('running', 'completed', 'failed', 'cancelled', 'stopped', 'timeout', 'preempted', 'out_of_memory')),
|
||||||
|
meta_data TEXT, -- JSON
|
||||||
|
resources TEXT NOT NULL, -- JSON
|
||||||
|
num_nodes INT NOT NULL,
|
||||||
|
num_hwthreads INT,
|
||||||
|
num_acc INT,
|
||||||
|
smt TINYINT NOT NULL DEFAULT 1 CHECK(smt IN (0, 1 )),
|
||||||
|
exclusive TINYINT NOT NULL DEFAULT 1 CHECK(exclusive IN (0, 1, 2)),
|
||||||
|
monitoring_status TINYINT NOT NULL DEFAULT 1 CHECK(monitoring_status IN (0, 1, 2, 3)),
|
||||||
|
mem_used_max REAL NOT NULL DEFAULT 0.0,
|
||||||
|
flops_any_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
mem_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
load_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
net_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
net_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
||||||
|
file_bw_avg REAL NOT NULL DEFAULT 0.0,
|
||||||
|
file_data_vol_total REAL NOT NULL DEFAULT 0.0,
|
||||||
|
UNIQUE (job_id, cluster, start_time));
|
||||||
|
|
||||||
|
INSERT INTO job_new SELECT * FROM job;
|
||||||
|
DROP TABLE job;
|
||||||
|
ALTER TABLE job_new RENAME TO job;
|
||||||
|
VACUUM;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS job_stats ON job (cluster,subcluster,user);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_user ON job (user);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_starttime ON job (start_time);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_by_job_id ON job (job_id, cluster, start_time);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list ON job (cluster, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_user ON job (user, cluster, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_users ON job (user, job_state);
|
||||||
|
CREATE INDEX IF NOT EXISTS job_list_users_start ON job (start_time, user, job_state);
|
Loading…
Reference in New Issue
Block a user