From b95ebb778209dd42966dc78eb3cddb7d6758b3f9 Mon Sep 17 00:00:00 2001 From: Jamesbarford Date: Wed, 11 Jun 2025 14:54:45 +0100 Subject: [PATCH 1/3] Create new table for `collector_config`, configuration for the collectors --- database/schema.md | 12 ++++++++++++ database/src/pool/postgres.rs | 11 +++++++++++ database/src/pool/sqlite.rs | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/database/schema.md b/database/schema.md index 8fb9d8657..eef507ebc 100644 --- a/database/schema.md +++ b/database/schema.md @@ -258,3 +258,15 @@ aid benchmark error ---------- --- ----- 1 syn-1.0.89 Failed to compile... ``` + +### collector_config + +Information about the collector; it's target architecture, when it was added, whether it is active and when it last had activity denoted by `last_heartbeat_at`. + +``` +sqlite> SELECT * FROM collector_config; + +id target date_added last_heartbeat_at benchmark_set is_active +--------- ------------------------- ------------- ---------------- --------- ------- +ea1f4e... aarch64-unknown-linux-gnu 2025-06-11... 2025-06-12 17... cea1bc... 0 +``` diff --git a/database/src/pool/postgres.rs b/database/src/pool/postgres.rs index 374b4904f..21604241f 100644 --- a/database/src/pool/postgres.rs +++ b/database/src/pool/postgres.rs @@ -285,6 +285,17 @@ static MIGRATIONS: &[&str] = &[ alter table pstat_series drop constraint test_case; alter table pstat_series add constraint test_case UNIQUE(crate, profile, scenario, backend, target, metric); "#, + r#"CREATE EXTENSION IF NOT EXISTS "uuid-ossp";"#, + r#" + CREATE TABLE IF NOT EXISTS collector_config ( + id UUID PRIMARY KEY, + target TEXT NOT NULL, + date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL, + last_heartbeat_at TIMESTAMPTZ, + benchmark_set UUID NOT NULL, + is_active BOOLEAN DEFAULT FALSE NOT NULL + ); + "#, ]; #[async_trait::async_trait] diff --git a/database/src/pool/sqlite.rs b/database/src/pool/sqlite.rs index 27d6b46de..120bbda33 100644 --- a/database/src/pool/sqlite.rs +++ b/database/src/pool/sqlite.rs @@ -404,6 +404,18 @@ static MIGRATIONS: &[Migration] = &[ alter table pstat_series_with_target rename to pstat_series; "#, ), + Migration::without_foreign_key_constraints( + r#" + CREATE TABLE IF NOT EXISTS collector_config ( + id TEXT PRIMARY KEY, + target TEXT NOT NULL, + date_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + last_heartbeat_at TIMESTAMP, + benchmark_set TEXT NOT NULL, + is_active BOOLEAN DEFAULT FALSE NOT NULL + ); + "#, + ), ]; #[async_trait::async_trait] From 69971ef88e1d8e899eb21f71cbc08fae2b878d02 Mon Sep 17 00:00:00 2001 From: Jamesbarford Date: Wed, 11 Jun 2025 15:47:35 +0100 Subject: [PATCH 2/3] PR feedback; use INTEGER rather than UUID --- database/schema.md | 2 +- database/src/pool/postgres.rs | 6 +++--- database/src/pool/sqlite.rs | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/database/schema.md b/database/schema.md index eef507ebc..d8ca23fc5 100644 --- a/database/schema.md +++ b/database/schema.md @@ -268,5 +268,5 @@ sqlite> SELECT * FROM collector_config; id target date_added last_heartbeat_at benchmark_set is_active --------- ------------------------- ------------- ---------------- --------- ------- -ea1f4e... aarch64-unknown-linux-gnu 2025-06-11... 2025-06-12 17... cea1bc... 0 +1 aarch64-unknown-linux-gnu 2025-06-11... 2025-06-12 17... 2 0 ``` diff --git a/database/src/pool/postgres.rs b/database/src/pool/postgres.rs index 21604241f..37a1deceb 100644 --- a/database/src/pool/postgres.rs +++ b/database/src/pool/postgres.rs @@ -285,14 +285,14 @@ static MIGRATIONS: &[&str] = &[ alter table pstat_series drop constraint test_case; alter table pstat_series add constraint test_case UNIQUE(crate, profile, scenario, backend, target, metric); "#, - r#"CREATE EXTENSION IF NOT EXISTS "uuid-ossp";"#, r#" CREATE TABLE IF NOT EXISTS collector_config ( - id UUID PRIMARY KEY, + id SERIAL PRIMARY KEY, target TEXT NOT NULL, + name TEXT NOT NULL, date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL, last_heartbeat_at TIMESTAMPTZ, - benchmark_set UUID NOT NULL, + benchmark_set INTEGER NOT NULL, is_active BOOLEAN DEFAULT FALSE NOT NULL ); "#, diff --git a/database/src/pool/sqlite.rs b/database/src/pool/sqlite.rs index 120bbda33..b022d576c 100644 --- a/database/src/pool/sqlite.rs +++ b/database/src/pool/sqlite.rs @@ -407,11 +407,12 @@ static MIGRATIONS: &[Migration] = &[ Migration::without_foreign_key_constraints( r#" CREATE TABLE IF NOT EXISTS collector_config ( - id TEXT PRIMARY KEY, + id INTEGER AUTO INCREMENT PRIMARY KEY, target TEXT NOT NULL, + name TEXT NOT NULL, date_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, last_heartbeat_at TIMESTAMP, - benchmark_set TEXT NOT NULL, + benchmark_set INTEGER NOT NULL, is_active BOOLEAN DEFAULT FALSE NOT NULL ); "#, From 34b927d872b8445af801966f2807e38f85c7f73c Mon Sep 17 00:00:00 2001 From: Jamesbarford Date: Thu, 12 Jun 2025 14:59:47 +0100 Subject: [PATCH 3/3] Pr feedback; add name to the schema doc and remove SQLite for the time being --- database/schema.md | 6 +++--- database/src/pool/sqlite.rs | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/database/schema.md b/database/schema.md index d8ca23fc5..b8983df76 100644 --- a/database/schema.md +++ b/database/schema.md @@ -266,7 +266,7 @@ Information about the collector; it's target architecture, when it was added, wh ``` sqlite> SELECT * FROM collector_config; -id target date_added last_heartbeat_at benchmark_set is_active ---------- ------------------------- ------------- ---------------- --------- ------- -1 aarch64-unknown-linux-gnu 2025-06-11... 2025-06-12 17... 2 0 +id target name date_added last_heartbeat_at benchmark_set is_active +--------- ------------------------- ---- ------------- ---------------- --------- ------- +1 aarch64-unknown-linux-gnu foo 2025-06-11... 2025-06-12 17... 2 0 ``` diff --git a/database/src/pool/sqlite.rs b/database/src/pool/sqlite.rs index b022d576c..27d6b46de 100644 --- a/database/src/pool/sqlite.rs +++ b/database/src/pool/sqlite.rs @@ -404,19 +404,6 @@ static MIGRATIONS: &[Migration] = &[ alter table pstat_series_with_target rename to pstat_series; "#, ), - Migration::without_foreign_key_constraints( - r#" - CREATE TABLE IF NOT EXISTS collector_config ( - id INTEGER AUTO INCREMENT PRIMARY KEY, - target TEXT NOT NULL, - name TEXT NOT NULL, - date_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, - last_heartbeat_at TIMESTAMP, - benchmark_set INTEGER NOT NULL, - is_active BOOLEAN DEFAULT FALSE NOT NULL - ); - "#, - ), ]; #[async_trait::async_trait]