Use PostgreSQL notifications for queue events
[?]
Jun 11, 2015, 3:38 PM
ATJ54SPXPE2IIFRERUOBFF42HBSEADP4QOI743ZBUNBQX3PYKRXQCDependencies
- [2]
W5OAZWPDDrop the errorMsg column in the Jobs table - [3]
RYTQLATYKeep track of failed paths in the Hydra database - [4]
C6HOMHZWDon't try to handle SIGINT - [5]
T2EIYJNGOn SIGINT, shut down the builder threads - [6]
NJJ7H64SVery basic multi-threaded queue runner - [7]
ENXUSMSVMake concurrency more robust - [8]
YZAI5GQUImplement a database connection pool - [9]
24BMQDZAStart of single-process hydra-queue-runner - [10]
5AIYUMTBBasic remote building - [*]
2GK5DOU7* Downloading closures. - [*]
UOINKJ2JAdd an action to cancel all builds in a jobset eval - [*]
N22GPKYT* Put info about logs / build products in the DB. - [*]
S6OISBQ3* Mark the "current" builds in a jobset, i.e. those corresponding to
Change contents
- edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 158[5.6816]→[5.20:59](∅→∅),[5.947]→[5.20:59](∅→∅),[5.59]→[5.75:123](∅→∅),[5.75]→[5.75:123](∅→∅),[5.123]→[5.60:94](∅→∅)
/* CV for waking up the queue. */std::condition_variable queueMonitorWakeup;std::mutex queueMonitorMutex; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 213
void getQueuedBuilds(std::shared_ptr<StoreAPI> store);void getQueuedBuilds(std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 365
auto conn(dbPool.get());struct receiver : public pqxx::notification_receiver{bool status = false;receiver(pqxx::connection_base & c, const std::string & channel): pqxx::notification_receiver(c, channel) { }void operator() (const string & payload, int pid) override{status = true;};bool get() {bool b = status;status = false;return b;}};receiver buildsAdded(*conn, "builds_added");receiver buildsRestarted(*conn, "builds_restarted");receiver buildsCancelled(*conn, "builds_cancelled"); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 388
unsigned int lastBuildId = 0; - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 392
getQueuedBuilds(store);getQueuedBuilds(store, lastBuildId);/* Sleep until we get notification from the database about anevent. */conn->await_notification(); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 398
{std::unique_lock<std::mutex> lock(queueMonitorMutex);queueMonitorWakeup.wait_for(lock, std::chrono::seconds(5));if (buildsAdded.get())printMsg(lvlError, "got notification: new builds added to the queue");if (buildsRestarted.get()) {printMsg(lvlError, "got notification: builds restarted");lastBuildId = 0; // check all builds}if (buildsCancelled.get()) {printMsg(lvlError, "got notification: builds cancelled"); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 413
void State::getQueuedBuilds(std::shared_ptr<StoreAPI> store)void State::getQueuedBuilds(std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId) - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 415
printMsg(lvlError, "checking the queue...");printMsg(lvlError, format("checking the queue for builds > %1%...") % lastBuildId); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 428
auto res = txn.exec("select * from Builds where finished = 0 order by id");auto res = txn.parameterized("select * from Builds where id > $1 and finished = 0 order by id")(lastBuildId).exec(); - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 433
if (id > lastBuildId) lastBuildId = id; - replacement in src/hydra-queue-runner/pool.hh at line 60
R * operator -> () { return r; }R * operator -> () { return r.get(); } - edit in src/lib/Hydra/Helper/Nix.pm at line 472
$db->storage->dbh->do("notify builds_restarted"); - edit in src/script/hydra-evaluator at line 249[2.799][15.5850]
$db->storage->dbh->do("notify builds_added");