Don't lock the BuildSteps table when inserting

[?]
Dec 7, 2017, 1:41 PM
XIFDDTXZZFGNUVXGHBW4FU4YYBFEMKLAYVRJ6HOPUHCDAF5HJFGAC

Dependencies

  • [2] LVQXQIYA Kill active build steps when builds are cancelled
  • [3] NTEDD7T4 Provide a plugin hook for when build steps finish
  • [4] KBZHIGLG Record the machine used for a build step
  • [5] 62MQPRXC Pass null values to libpqxx properly
  • [6] LJILHOJ7 Create BuildSteps race-free
  • [7] 24BMQDZA Start of single-process hydra-queue-runner
  • [8] MSIHMO45 Tweak build steps
  • [9] HUUZFPPK Fix race between the queue monitor and the builder threads
  • [10] VQISTKOP hydra-queue-runner: Use substitutes
  • [*] UQQ4IL55 Add a error type for "unsupported system type"

Change contents

  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 283
    [3.8256][3.0:198]()
    /* Acquire an exclusive lock on BuildSteps to ensure that we don't
    race with other threads creating a step of the same build. */
    txn.exec("lock table BuildSteps in exclusive mode");
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 291
    [3.339]
    [2.2914]
    restart:
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 294
    [3.8432][3.93:115](),[3.115][3.375:578]()
    txn.parameterized
    ("insert into BuildSteps (build, stepnr, type, drvPath, busy, startTime, system, status, propagatedFrom, errorMsg, stopTime, machine) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)")
    [3.8432]
    [2.2963]
    auto r = txn.parameterized
    ("insert into BuildSteps (build, stepnr, type, drvPath, busy, startTime, system, status, propagatedFrom, errorMsg, stopTime, machine) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) on conflict do nothing")
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 308
    [12.75]
    [3.8996]
    if (r.affected_rows() == 0) goto restart;
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 341
    [3.691]
    [2.3055]
    restart:
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 344
    [3.737][3.737:900]()
    txn.parameterized
    ("insert into BuildSteps (build, stepnr, type, drvPath, busy, status, startTime, stopTime) values ($1, $2, $3, $4, $5, $6, $7, $8)")
    [3.737]
    [3.900]
    auto r = txn.parameterized
    ("insert into BuildSteps (build, stepnr, type, drvPath, busy, status, startTime, stopTime) values ($1, $2, $3, $4, $5, $6, $7, $8) on conflict do nothing")
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 354
    [3.1057]
    [3.1057]
    if (r.affected_rows() == 0) goto restart;