Support cancelling builds

[?]
Jun 11, 2015, 4:07 PM
2IQRXLWETU2RLXPYKBSZIUULDHS346BAHE2NLOMOWXC6WDAX2BYQC

Dependencies

  • [2] ATJ54SPX Use PostgreSQL notifications for queue events
  • [3] ENXUSMSV Make concurrency more robust
  • [4] 5AIYUMTB Basic remote building
  • [5] C6HOMHZW Don't try to handle SIGINT
  • [6] 24BMQDZA Start of single-process hydra-queue-runner
  • [7] YZAI5GQU Implement a database connection pool
  • [8] NJJ7H64S Very basic multi-threaded queue runner
  • [9] T2EIYJNG On SIGINT, shut down the builder threads
  • [*] 2GK5DOU7 * Downloading closures.
  • [*] UOINKJ2J Add an action to cancel all builds in a jobset eval

Change contents

  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 212
    [3.198]
    [3.1057]
    void getQueuedBuilds(Connection & conn, std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId);
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 215
    [3.1058][2.0:87]()
    void getQueuedBuilds(std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId);
    [3.1058]
    [3.7042]
    void removeCancelledBuilds(Connection & conn);
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 394
    [3.19][2.775:820]()
    getQueuedBuilds(store, lastBuildId);
    [3.19]
    [2.820]
    getQueuedBuilds(*conn, store, lastBuildId);
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 408
    [2.1336]
    [3.1739]
    removeCancelledBuilds(*conn);
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 416
    [3.1807][2.1337:1426]()
    void State::getQueuedBuilds(std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId)
    [3.1807]
    [3.9878]
    void State::getQueuedBuilds(Connection & conn, std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId)
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 419
    [2.1515][3.543:573](),[3.1943][3.543:573]()
    auto conn(dbPool.get());
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 425
    [3.1805][3.574:605]()
    pqxx::work txn(*conn);
    [3.1805]
    [3.1835]
    pqxx::work txn(conn);
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 427
    [3.1836][3.1836:1925]()
    // FIXME: query only builds with ID higher than the previous
    // highest.
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 456
    [3.9876][3.606:641](),[3.10582][3.606:641]()
    pqxx::work txn(*conn);
    [3.9876]
    [3.10645]
    pqxx::work txn(conn);
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 478
    [3.11214][3.642:677]()
    pqxx::work txn(*conn);
    [3.11214]
    [3.11277]
    pqxx::work txn(conn);
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 513
    [3.11514]
    [3.3982]
    void State::removeCancelledBuilds(Connection & conn)
    {
    /* Get the current set of queued builds. */
    std::set<BuildID> currentIds;
    {
    pqxx::work txn(conn);
    auto res = txn.exec("select id from Builds where finished = 0");
    for (auto const & row : res)
    currentIds.insert(row["id"].as<BuildID>());
    }
    auto builds_(builds.lock());
    for (auto i = builds_->begin(); i != builds_->end(); ) {
    if (currentIds.find(i->first) == currentIds.end()) {
    printMsg(lvlInfo, format("discarding cancelled build %1%") % i->first);
    i = builds_->erase(i);
    // FIXME: ideally we would interrupt active build steps here.
    } else
    ++i;
    }
    }
  • edit in src/lib/Hydra/Helper/Nix.pm at line 436
    [12.1589]
    [12.1589]
    $db->storage->dbh->do("notify builds_cancelled");