Fix a race that can cause hydra-queue-runner to ignore newly added builds

[?]
Jul 21, 2017, 12:25 PM
S2NXJOJE3V7PTXHA2HAHA5BUSNJRHZNXBWK7KSWTPGISWKXYMJDQC

Dependencies

  • [2] OG3Z3QGC Namespace cleanup
  • [3] H4KMCXGU Use triggers for all notifications on Builds table changes
  • [4] MHVIT4JY Split hydra-queue-runner.cc more
  • [5] RVHBV3B3 Notify the queue runner when a build is deleted
  • [6] PHX2HIVG * Store info about the build inputs in the build record.
  • [7] ZK76B5ZZ Load the queue in order of global priority
  • [8] 73YR46NJ hydra-queue-runner: Write directly to a binary cache
  • [9] HJOEIMLR Refactor
  • [10] RND7XFNH getQueuedBuilds(): Periodically stop to handle priority bumps
  • [11] DKJFD6JN Process Nix API changes
  • [12] WE5Q2NVI Allow build to be bumped to the front of the queue via the web interface
  • [*] N22GPKYT * Put info about logs / build products in the DB.
  • [*] TJK27WSB Open the DB using Hydra::Model::DB->new
  • [*] WQXF2T3D hydra-evaluator: Don't require $HYDRA_CONFIG
  • [*] DDGBLKEN Update isCurrent properly
  • [*] DDMYFZ5X Fix the jobset unchanged check
  • [*] D5QIOJGP * Move everything up one directory.

Change contents

  • replacement in src/hydra-queue-runner/queue-monitor.cc at line 51
    [4.21027][4.21027:21058]()
    if (buildsAdded.get())
    [4.21027]
    [4.21058]
    if (auto lowestId = buildsAdded.get()) {
    lastBuildId = std::stoi(*lowestId) - 1;
  • edit in src/hydra-queue-runner/queue-monitor.cc at line 54
    [4.21145]
    [4.21145]
    }
  • replacement in src/hydra-queue-runner/queue-monitor.cc at line 80
    [4.21622][4.21622:21709]()
    printMsg(lvlInfo, format("checking the queue for builds > %1%...") % lastBuildId);
    [4.21622]
    [4.21709]
    printInfo("checking the queue for builds > %d...", lastBuildId);
  • replacement in src/libhydra/db.hh at line 24
    [5.626][5.626:679]()
    struct receiver : public pqxx::notification_receiver
    [5.626]
    [5.679]
    class receiver : public pqxx::notification_receiver
  • replacement in src/libhydra/db.hh at line 26
    [5.681][5.681:706]()
    bool status = false;
    [5.681]
    [5.706]
    std::experimental::optional<std::string> status;
    public:
  • edit in src/libhydra/db.hh at line 32
    [5.829]
    [2.216]
  • replacement in src/libhydra/db.hh at line 35
    [5.898][5.898:921]()
    status = true;
    [5.898]
    [5.921]
    status = payload;
  • replacement in src/libhydra/db.hh at line 37
    [5.928][5.928:1012]()
    bool get() {
    bool b = status;
    status = false;
    return b;
    [5.928]
    [5.1012]
    std::experimental::optional<std::string> get() {
    auto s = status;
    status = std::experimental::nullopt;
    return s;
  • edit in src/script/hydra-eval-jobset at line 28
    [15.745]
    [16.961]
    my $notifyAdded = $db->storage->dbh->prepare("notify builds_added, ?");
  • edit in src/script/hydra-eval-jobset at line 725
    [17.51]
    [18.518]
    # Wake up hydra-queue-runner.
    my $lowestId;
    while (my ($id, $x) = each %buildMap) {
    $lowestId = $id if $x->{new} && (!defined $lowestId || $id < $lowestId);
    }
    $notifyAdded->execute($lowestId) if defined $lowestId;
  • edit in src/sql/hydra.sql at line 236
    [3.1][3.1:210](),[3.210][5.135:136](),[5.135][5.135:136]()
    create function notifyBuildsAdded() returns trigger as 'begin notify builds_added; return null; end;' language plpgsql;
    create trigger BuildsAdded after insert on Builds execute procedure notifyBuildsAdded();
  • file addition: upgrade-54.sql (----------)
    [19.3004]
    drop trigger BuildsAdded on Builds;
    drop function notifyBuildsAdded();