hydra-queue-runner: Handle status queries on the main thread

[?]
Jun 17, 2015, 11:57 PM
XV4AEKJCFTNCOR52IRFYHORCNNFKIHOADIUARTC2U5Z6ZQBEEFYQC

Dependencies

  • [2] RQUAATWB Add status dump facility
  • [3] CCHPYTCP hydra-queue-runner: Handle $HYDRA_DBI
  • [4] ATJ54SPX Use PostgreSQL notifications for queue events
  • [5] NJJ7H64S Very basic multi-threaded queue runner
  • [*] 24BMQDZA Start of single-process hydra-queue-runner
  • [*] C6HOMHZW Don't try to handle SIGINT
  • [*] T2EIYJNG On SIGINT, shut down the builder threads

Change contents

  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 83
    [3.403]
    [3.403]
    }
    };
    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;
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 454
    [4.117][4.117:573]()
    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;
    }
    };
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 458
    [4.737][2.116:163]()
    receiver dumpStatus(*conn, "dump_status");
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 482
    [2.192][2.192:255]()
    if (dumpStatus.get())
    State::dumpStatus();
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1314
    [8.92]
    [9.771]
    while (true) {
    try {
    auto conn(dbPool.get());
    receiver dumpStatus(*conn, "dump_status");
    while (true) {
    conn->await_notification();
    if (dumpStatus.get())
    State::dumpStatus();
    }
    } catch (std::exception & e) {
    printMsg(lvlError, format("main thread: %1%") % e.what());
    sleep(10); // probably a DB problem, so don't retry right away
    }
    }
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 1330
    [9.772]
    [4.3479]
    // Never reached.