From 89fb723ace6745b1f1455878ac5df8efe6d0495a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 Jul 2015 11:43:35 +0200 Subject: [PATCH] Notify the queue runner when a build is deleted --- src/hydra-queue-runner/hydra-queue-runner.cc | 3 ++- src/sql/hydra.sql | 16 ++++++++++++++++ src/sql/upgrade-35.sql | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/sql/upgrade-35.sql diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 892e8103..a07ec55f 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -206,6 +206,7 @@ void State::queueMonitorLoop() receiver buildsAdded(*conn, "builds_added"); receiver buildsRestarted(*conn, "builds_restarted"); receiver buildsCancelled(*conn, "builds_cancelled"); + receiver buildsDeleted(*conn, "builds_deleted"); auto store = openStore(); // FIXME: pool @@ -225,7 +226,7 @@ void State::queueMonitorLoop() printMsg(lvlTalkative, "got notification: builds restarted"); lastBuildId = 0; // check all builds } - if (buildsCancelled.get()) { + if (buildsCancelled.get() || buildsDeleted.get()) { printMsg(lvlTalkative, "got notification: builds cancelled"); removeCancelledBuilds(*conn); } diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 2bbb04d4..1a6f6938 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -202,6 +202,22 @@ create table Builds ( ); +#ifdef POSTGRESQL + +create function notifyBuildDeleted() returns trigger as $$ + begin + execute 'notify builds_deleted'; + return null; + end; +$$ language plpgsql; + +create trigger BuildDeleted after delete on Builds + for each row + execute procedure notifyBuildDeleted(); + +#endif + + create table BuildOutputs ( build integer not null, name text not null, diff --git a/src/sql/upgrade-35.sql b/src/sql/upgrade-35.sql new file mode 100644 index 00000000..9d05c770 --- /dev/null +++ b/src/sql/upgrade-35.sql @@ -0,0 +1,10 @@ +create function notifyBuildDeleted() returns trigger as $$ + begin + execute 'notify builds_deleted'; + return null; + end; +$$ language plpgsql; + +create trigger BuildDeleted after delete on Builds + for each row + execute procedure notifyBuildDeleted();