Skip to content

Persistent runner drops the next job when it aborts its Busy long-poll at job completion ("was not acquired by Runner") #4728

Open

Description

@osazemeu

Describe the bug

When a job finishes, OnJobStatus (src/Runner.Listener/BrokerMessageListener.cs, and the same code in MessageListener.cs) sets _runnerStatus = Online and cancels _getMessagesTokenSource, aborting the GET /message?status=Busy long-poll that is still open. The service assigns the next queued job to the runner at that same moment and delivers it on that open poll. Aborting the request drops the message on the client, while the service treats it as delivered.

The service redelivers roughly 61 s later. By then the assignment has expired: acknowledge returns 404, acquirejob returns 409 MissingKey, and the runner logs "Skipping message Job". After repeated misses the job is cancelled with the check-run annotation:

The job was not acquired by Runner of type self-hosted even after multiple attempts

The job has no runner name and zero steps. Any aggregate job that needs: it then fails the workflow run.

Evidence (runner 2.337.0, Linux x64, persistent runner, repo-scoped)

[2026-09-19 01:41:43Z INFO Terminal] WRITE LINE: Job Release Validation (prod) completed with result: Succeeded
[2026-09-19 01:41:43Z WARN GitHubActionsService] GET request to https://broker.actions.githubusercontent.com/message?sessionId=...&status=Busy&runnerVersion=2.337.0... has been cancelled
[2026-09-19 01:41:43Z INFO BrokerMessageListener] Get messages has been cancelled using local token source. Continue to get messages with new status.
[2026-09-19 01:42:44Z INFO BrokerMessageListener] Acknowledging runner request '07f09524-...'.
[2026-09-19 01:42:44Z ERR  GitHubActionsService] POST request to https://broker.actions.githubusercontent.com/acknowledge?...&status=Online... failed. HTTP Status: NotFound
[2026-09-19 01:42:45Z ERR  GitHubActionsService] POST request to https://run-actions-3-azure-eastus.actions.githubusercontent.com/104/acquirejob failed. HTTP Status: Conflict
[2026-09-19 01:42:45Z INFO Runner] Skipping message Job. Job message already acquired '07f09524-...'. job assignment is invalid: MissingKey

A fresh status=Online poll opens at 01:41:43 but receives nothing until the 61 s redelivery. If the job had been queued service-side, that poll would have returned it immediately, so the first delivery went out on the aborted Busy poll.

Frequency

The client code is unchanged since 2.336.0 (our 2.336.0 logs show the same abort on every job completion). What changed is the rate, starting around 2026-09-13, which suggests a service-side change in when the next job is dispatched. MissingKey lines per day across two runners on one host:

Date MissingKey Jobs run
2026-08-26 to 2026-09-06 6 total
2026-09-13 9 148
2026-09-16 17 215
2026-09-17 31 229
2026-09-19 20 53

Most misses are redelivered to the other runner in time. The rest end as cancelled, runner-less jobs: 6 in the last three days, all in a matrix that queues about a dozen jobs against two runners, which is where job-completion handoffs are densest.

To reproduce

Two persistent runners, one matrix of 10+ short jobs so the queue stays non-empty while jobs complete. Watch _diag/Runner_*.log for "cancelled using local token source" followed about 60 s later by acquirejob 409 MissingKey.

Expected behavior

A job assigned at completion time is received and run by the runner it was assigned to.

Suggested fix

Do not abort the in-flight poll on the Busy to Online transition. The service already knows the job completed, and it assigns work on the Busy poll, so letting that poll return delivers the job. _runnerStatus is still updated and goes out on the next poll. Fix in #4729.

Related

Runner version and platform

2.337.0 (behaviour present in 2.336.0), Linux x64, systemd-managed persistent runners, repository scope.

Activity

  1. rldyourmnd commented on Sep 27, 2026

    @rldyourmnd

    Independent reproduction on 2.337.0, from organization-scoped persistent runners (Linux x64, Docker-enabled, several orgs, about 30 slots across two hosts). The signature is the same as above: the Busy long-poll is cancelled at job completion, about 61 s later acknowledge returns 404 and acquirejob returns 409 MissingKey, and the job ends as "not acquired by Runner of type self-hosted even after multiple attempts" with runner_id: 0 and no steps.

    Numbers from our runners' _diag logs, 2026-09-17 to 2026-09-27:

    • Two slots of one org logged 329 and 293 MissingKey skips.
    • Across 39 private repositories, 25 jobs failed as "not acquired" in three days. Every one had runner_id: 0 and the annotation above; none had started a step.
    • Most skips are harmless because the redelivery reaches another idle runner of the same scope. A job fails when the redelivery keeps landing on busy runners. With one runner per host per org, a single long-running job on the other host (a 12-minute polling job, in our case) was enough to lose the next job twice in one day.

    A second runner per host per org makes it rarer but does not remove it. As a stopgap we rerun, from a workflow_run workflow, only those failed jobs where every failure carries this annotation and runner_id == 0.

    The fix in #4729 (keep the Busy poll open through the Busy→Online transition) matches everything we see. We'd pick up a release with it immediately.

  2. added a commit that references this issue on Sep 27, 2026
    2f1e849
  3. adamrefactored commented on Sep 28, 2026

    @adamrefactored

    Another independent reproduction on 2.337.0, repo-scoped persistent runners (Linux x64, 12 runners on one host, CPU-quota'd systemd units, egress via a local HTTP proxy).

    Same signature as the issue: Get messages has been cancelled using local token source at job completion, then later:

    ERR  GitHubActionsService] POST request to https://…/acquirejob failed. HTTP Status: Conflict
    INFO Runner] Skipping message Job. Job message already acquired '<job>'. job assignment is invalid: MissingKey
    

    and the job ends with "The job was not acquired by Runner of type self-hosted even after multiple attempts" (no runner name, zero steps).

    Observations that may help:

    • Load-dependent: 3 occurrences in ~3 h under merge-queue load (2026-09-26 08:30–11:45Z), zero over a quiet weekend, and ~1 per busy PR cycle once load returned (2026-09-28 19:00–21:10Z). It needs a queued job at a job-completion instant, which fits the mechanism described above.
    • In one case the dropped job's check was cancelled at 08:49:48Z and the acquirejob 409 MissingKey on the runner that had received it is logged at 08:49:49Z.
    • In a merge-queue context the impact is amplified: a dropped required job dequeues the whole candidate although every test that ran passed.
    • We ruled out our egress proxy as the cause: it has its own saturation events, but they don't coincide with the drops.

    Happy to provide more _diag excerpts if useful.

  4. added 5 commits that reference this issue on Sep 30, 2026
    0f83fdb
    a1fde7a
    831d658
    7a4af2f
    95b52ee
  5. joel-n6 commented on Oct 5, 2026

    @joel-n6

    Another independent reproduction on 2.337.0, this time on Linux ARM64: a single repo-scoped persistent runner (Runner.Listener run --startuptype service) in an Ubuntu VM on Apple silicon. It is the only runner with its label.

    It has the same signature. When a job finishes, the runner logs that its GET /message?...&status=Busy was cancelled, followed by TaskCanceledException and Get messages has been cancelled using local token source. Continue to get messages with new status.. The job that had been queued in that same second is never logged as received. A second later the runner acknowledges and runs the next queued job. About 10 minutes later the dropped job is cancelled as "not acquired by Runner … even after multiple attempts", with no runner name.

    Some data points that may help:

    • Timing: every job we lost was queued 0–1 s after the previous job's completed_at on the same runner. Jobs queued about 2 s or more later were always picked up.
    • Matrix fan-out: on one day, this failed 6 of 20 release runs. Each time it was the first leg of a 7-leg matrix that was queued all at once as its needs: job finished.
    • Workaround, partial: strategy.max-parallel: 1 removed the 0 s offers inside the matrix workflow. Each leg is then queued about 2 s after the previous one finishes, and the next several runs were clean. A separate workflow of single dependent jobs on the same runner still lost a job twice, at 0 s and 1 s gaps. So the workaround narrows the window but doesn't close it, which is consistent with the client-side cause and the fix in Keep the Busy long-poll open when a job completes #4729.
    • No other runner to pick up redeliveries: with only one runner on the label, nothing else can take a redelivered job, so every missed offer becomes a cancelled job.
  6. varlikiq-degerleme commented on Oct 5, 2026

    @varlikiq-degerleme

    Another independent reproduction on 2.337.0, Linux x64, repo-scoped persistent runners: 30 runners on one VM share the job label, plus 2 runners with a different label on the same VM, same NIC.

    Same signature. We classified every Acknowledging runner request in all _diag/Runner_*.log files (2026-09-22 to 2026-10-05) by how long after the preceding Get messages has been cancelled using local token source it arrived. Only the first message after that line was counted.

    First message after a job completed, arrived... Messages acknowledge 404 Rate
    0-5 s later 19,929 2 0.0 %
    6-55 s later 1,377 0 0.0 %
    56-65 s later 3,903 1,951 50 %
    > 65 s later 4,555 8 0.2 %
    any later message 2,322 1 0.0 %

    That is 1,951 of 1,964 failures (99.3 %) in exactly the window described here. The other half of the 56-65 s bucket is most likely genuinely new jobs that arrived at the end of a long poll.

    Two more observations:

    • The queue is the precondition, not the network. On the same VM and NIC, the 2 runners whose label rarely has a backlog logged 0 failures in 677 job completions over a weekend. In the same days the 30 saturated runners failed on 11.8 % and 8.9 % of job completions.

    • The rate depends on the day, not on load. Failures per job completion:

      Days Failure rate
      Weekdays 0.5-3.2 %
      2026-09-26/27 (weekend) 14.8 % / 20.4 %
      2026-10-03/04 (weekend) 11.8 % / 8.9 %

      A job was waiting at 92.5 % of job completions on a 0.6 % weekday, so a busier queue does not explain the rise. That pattern fits the service-side timing change suggested above.

    GitHub side: over 2026-10-03 to 2026-10-05, 99 jobs were cancelled with "not acquired by Runner of type self-hosted even after multiple attempts". They hit 66 of 354 workflow run attempts (19 %). Median queue time before the cancel was 22.6 min (max 47.6). Our stopgap is the same as the one above: a workflow_run workflow that reruns only when every failure carries this annotation and runner_id == 0.

    #4729 matches everything we measured. A review/release would help a lot of self-hosted users.

  7. added 2 commits that reference this issue on Oct 6, 2026
    964126e
    b20eabd
  8. EmreClynx commented on Oct 9, 2026

    @EmreClynx

    Adding evidence from another deployment hitting what looks like the same race, in case it helps prioritise #4729.
    Setup: self-hosted persistent runners, v2.337.0 (also observed before the bump), Ubuntu 24.04, two hosts, ~16–18 runner instances per host, label-based routing, reusable workflow with ~24 parallel test shards per PR.
    Symptom: jobs end up conclusion=cancelled with runner_id=0, runner_name="" and no steps, roughly 60 s after being queued, while idle runners with matching labels were online. The affected runners' _diag logs show a Busy→Online transition right before, followed by 409 MissingKey on the next acquire. Nothing in the job's own logs (it never started).
    Numbers (one 4 h window, 2026-10-04):
    372 Busy→Online transitions across the fleet, 44 MissingKey rejections.
    14 of 50 workflow runs lost at least one job this way.
    Correlated 6 cancelled jobs with the runner that had just finished a job on the same label (same host and ±2 s), in 6/6 cases.

  9. karthiyts commented on Oct 13, 2026

    @karthiyts

    Another reproduction on 2.337.0: organization-scoped persistent runners, Linux x64, 5 runners on one host.

    8 jobs lost since 2026-09-22, all from a 12-shard jest matrix plus a 4-shard Playwright matrix.

    • 6 of 8 match exactly. The lost job's GUID (the check-run external_id) shows up in exactly one runner's _diag, 60–61 s after that runner's Busy poll was cancelled. Then acknowledge returns 404, acquirejob returns 409 MissingKey, and the runner skips it. The job is never offered again and is cancelled at ~14 min.
    • The other 2 never appear in any runner's log. The first delivery was lost and nothing redelivered it.

    Stopgap: a workflow_run workflow that re-runs only when every failure carries the "not acquired" annotation.

    +1 for #4729.

  10. Joudelbosc commented on Oct 13, 2026

    @Joudelbosc

    Another independent reproduction on 2.337.0, with an onset date that differs from the one in the issue.

    Setup: two repo-scoped persistent runners on two hosts, Linux x64, one job at a time each, run.sh under a systemd user unit, label-based routing. Runner A is Ubuntu 26.04 under WSL2 (kernel 6.18); runner B is Ubuntu 26.04 on bare metal. Both have been on 2.337.0 since at least 2026-09-30.

    Same signature, line for line: Get messages has been cancelled using local token source at job completion, then 60–61 s later acknowledge → 404, acquirejob → 409, Skipping message Job ... job assignment is invalid: MissingKey.

    Rate. MissingKey lines against Running job: lines in _diag/Runner_*.log:

    Runner, period (UTC) Jobs run MissingKey
    A, 2026-09-13 to 2026-10-07 (14 days with activity) 6415 22
    A, listener logs started 2026-10-08 216 20
    A, listener logs started 2026-10-09 375 99
    A, listener logs started 2026-10-11 304 83
    A, 2026-10-12 20:33 to 2026-10-13 11:20 92 47
    B, 2026-10-12 19:02 (first registered) to 2026-10-13 11:25 173 74

    For us the rate was near zero until 2026-10-07 and jumped on 2026-10-08, with no runner upgrade on our side; the only workflow edit that day added two test scripts to one existing job. Runner B did not exist until 2026-10-12, so the jump on A happened while it was the only runner in the repository. A listener restart on 2026-10-12 20:33 did not change it.

    Lost jobs. Between 2026-10-12 17:00 and 2026-10-13 10:10, 25 jobs ended cancelled with no runner, zero steps and the "was not acquired by Runner of type self-hosted even after multiple attempts" annotation (counted through the API over every run attempt). They hit both runners, and 9 of them carried a label that only runner A serves, so a second runner with the same label is not required to lose the job. Each one failed the aggregate job that needs: it; 11 manual rerun --failed on 2026-10-13.

    One lost job, three deliveries, all late. A job that only runner A could take:

    Busy poll cancelled (job completion) Redelivery acknowledged Result
    22:36:07 22:37:07 404, then 409 MissingKey
    22:46:47 22:47:48 404, then 409 MissingKey
    22:54:19 22:55:20 404, then 409 MissingKey

    After the third miss the job was cancelled. Each time the runner picked up a different queued job one or two seconds later, so it was idle and polling when the stale delivery arrived.

    Happy to share redacted _diag excerpts if they help with #4729.

  11. dsmirnoff73 commented on Nov 7, 2026

    @dsmirnoff73

    Another reproduction, on 2.338.2, Linux ARM64, organization-scoped persistent runners: 8 runner processes on one host, label-based routing.

    Stock 2.338.2. We counted, in _diag/Runner_*.log, the time from Get messages has been cancelled using local token source to the next Acknowledging runner request (only the first message after each cancel). We used 7 runners over about 3 days:

    First message after a job completed Count
    0–5 s 413
    56–65 s 414
    other (no queued job at that moment) 1,171

    MissingKey happened 2 times. In most cases the redelivery reached the same runner in time, so the cost was the ~61 s idle gap, not a lost job.

    With #4729 applied (2.338.2 + the PR diff, built with dev.sh layout). We first ran it on one runner, then on all 8:

    • There are no more cancelled using local token source lines. When a job was queued at the moment of completion, the next job came in 0–5 s (7 of 7 such cases on the canary).
    • But a new gap appeared, because the open poll still reports Busy. The service does use that status for dispatch, so a runner that has finished a job is not offered new jobs until that poll ends. Two cases:
      • A runner finished a job and stayed idle with no log activity for 4 min 46 s. Then 5 jobs were queued at the same second. Four other runners took four of them in 1 s; those runners had not run a job since their restart, so their polls were Online. The idle runner received the fifth job 61 s after it was queued.
      • A runner finished a job, and a dependent job was queued in the same second. There was no cancel line, and the runner acknowledged the job 62 s later. Other runners were idle at that time.

    So in our setup #4729 moves the ~61 s gap rather than removing it, and we rolled back to stock.

    With a short grace instead. We then changed OnJobStatus in both listeners: on Online, _getMessagesTokenSource?.CancelAfter(TimeSpan.FromSeconds(3)); on other statuses, Cancel() as before. The open poll can still receive a job that the service sends at completion, and the next poll reports Online about 3 s later. Each poll has its own token source, which is disposed in finally, so a pending timer cannot cancel a later poll. First results (one runner, then all 8; small sample so far):

    • A job queued at the moment of completion was acknowledged 0–1 s after the job ended (3 of 3 on the canary). There were no redeliveries.
    • No job waited while a runner was idle. The only waits were in a burst with all runners busy, and those jobs started about 2 s after a runner was free.

    We are happy to open this as a PR if it helps. A service-side change would be cleaner.

  12. Petr-Trader commented on Nov 8, 2026

    @Petr-Trader

    Another reproduction, on a single repo-scoped persistent runner (Linux x64, Ubuntu under WSL2). Versions 2.337.0, 2.338.0 (from 2026-10-26) and 2.338.2 (from 2026-11-04), all self-updated. It is the only runner with its label.

    The signature is the same, with one difference. On this runner the late redelivery's acknowledge succeeds, and then acquirejob hangs until the client-side timeout. The 409 comes on the retry:

    [..Z INFO Terminal] WRITE LINE: ... Job <name> completed with result: Succeeded
    [..Z INFO BrokerMessageListener] Get messages has been cancelled using local token source. Continue to get messages with new status.
                                                        (+61 s)
    [..Z INFO BrokerMessageListener] Acknowledging runner request '<id>'.
                                                        (+100 s)
    [..Z WARN GitHubActionsService] POST request to https://run-actions-<n>-azure-eastus.actions.githubusercontent.com/<n>/acquirejob timed out after 100 seconds.
    [..Z ERR  GitHubActionsService] POST request to https://run-actions-<n>-azure-eastus.actions.githubusercontent.com/<n>/acquirejob failed. HTTP Status: Conflict
    [..Z INFO Runner] Skipping message Job. Job message already acquired '<id>'. job assignment is invalid: MissingKey
    

    Numbers from _diag/Runner_*.log, 2026-10-14 to 2026-11-07: 1,460 job messages (Acknowledging runner request) and 94 MissingKey skips. Each skip is matched to its message by request ID (all 94 match). Each message is classified by how long after the preceding cancelled using local token source it arrived. Only the first message after each cancel counts; a message with no preceding cancel counts as idle.

    Message arrived Messages MissingKey skips of which: own acquirejob timed out first
    0–5 s after a job completed 796 34 (4.3 %) 32
    56–65 s after (late redelivery) 312 40 (12.8 %) 32
    other gap 140 16 (11.4 %) 11
    runner idle, no preceding cancel 212 4 (1.9 %) 4
    total 1,460 94 79
    • The late-redelivery path is about 3× riskier than a message arriving right after completion (12.8 % vs 4.3 %). This matches the race described here, and Keep the Busy long-poll open when a job completes #4729 or the 3 s grace from the previous comment should remove that part.
    • 54 of our 94 skips are not late redeliveries. Most of them (34) are messages that arrived within 5 s of a job completing. There, acquirejob timed out after 100 s and the retry got 409 MissingKey.
    • In 79 of the 94 skips, the runner's own acquirejob for that same request timed out (100 s) between Acknowledging and the skip. This also holds for 32 of the 40 late redeliveries: on our runner they hang first instead of failing fast.
    • The acquirejob timeout rate per message was the same on 2.337.0 and 2.338.x. We ruled out an MTU/MSS problem (clamping MSS changed nothing). A probe from the same host shows occasional TCP connect timeouts (SYN unanswered for 30 s) to the run-actions-*-azure-eastus hosts from inside WSL2, while the Windows host in the same minutes connected fine. So at least some of these timeouts are probably on our side (WSL2/NAT), not in the service. That is still a single run, not proof.

    Whatever the cause of the timeout, the result is the same: by the time the retry arrives, the assignment is no longer valid (MissingKey), and the runner drops the job silently. That happens whether the first request reached the service or never got through. With one runner the job then waits until something else delivers a new message: a new job, or a restart. Our workaround is a watchdog that queues a small workflow_dispatch job whenever eligible jobs sit queued while the runner is idle.

    Suggestion for that second path, alongside #4729: when acquirejob returns 409 MissingKey right after this runner's own acquirejob for the same request timed out, the job should not be lost silently. The service could re-offer an assignment that expired without being acquired, or the runner could log it as an error, not as an informational "skipping" line. Today a transient client-side timeout turns into a job that waits until an unrelated event.

    Happy to share more redacted _diag excerpts.

  13. osazemeu commented on Nov 9, 2026

    @osazemeu
    Author

    Thanks for the numbers. A correction to my first version of this reply, and two follow-ups.

    What we see with the original #4729 (keep the Busy poll open on Online, no grace). Six org-scoped persistent runners, Linux x64, one host, 2.338.2 plus that change since 2026-10-26 and an earlier build of it since 2026-09-19. Checked 2026-11-07 against API queue times for 2026-10-31 to 2026-11-07:

    Job queued relative to a runner's completion Jobs Acknowledged within 5 s
    0 to 1 s after 176 176
    2 to 55 s after 146 146

    One job of 1,389 queued before a completion arrived 61 s late. MissingKey was 15 across all six runners from 2026-10-01 to 2026-11-07, 6 of them in one minute on 2026-10-12. So the idle gap @dsmirnoff73 measured on ARM64 does not reproduce here. I said earlier that their measurement was right; on this setup it is not, and I should not have stated it for every platform.

    #4729 now also contains a 3 s grace variant (CancelAfter(3 s) on Online) as a draft, because it did remove the gap on their runners. It is not verified in CI or in production yet, and we do not run it.

    Questions for @dsmirnoff73:

    1. How do the runners differ from the above: ARM64 only, eight runner processes on one host, label-based routing? Is the runner-to-job pattern one where several jobs finish within the same second?
    2. Does the Busy poll after completion ever deliver a job to a runner that has no other work, or only to the runner that just finished one? In our logs it does the former.

    Question for @Petr-Trader:

    1. The 56 to 65 s late-redelivery rows in your table are the race in this issue. The 79 skips that follow a 100 s acquirejob timeout are a different path, and Keep the Busy long-poll open when a job completes #4729 does not change them. Do the timeouts also occur on a job that arrives after the runner has been idle for minutes, and does the same host stay reachable on run-actions-*-azure-eastus from a second WSL2 distro or with networkingMode=mirrored?
  14. Petr-Trader commented on Nov 9, 2026

    @Petr-Trader

    @osazemeu Thanks for separating the two paths — that matches what we see.

    Q1 (timeouts on idle-arriving jobs). Yes, a few do. From the same _diag set (2026-10-14 to 2026-11-07, 1,460 messages, 94 MissingKey skips), the "runner idle, no preceding cancel" bucket is 212 messages with 4 skips (1.9%), and all 4 had this runner's own acquirejob time out first. So the 100 s acquirejob timeouts are not tied to a preceding completion. The idle rate (1.9%) is well below the post-completion buckets (4.3% at 0–5 s, 12.8% at 56–65 s), so most cluster near completions, but the idle cases confirm the client-side timeout path is independently present. That is consistent with a network-layer issue separate from the #4728 completion race (and separate from what #4729 changes).

    Q2 (network path / mirrored networking). Good call — we'll test it. Plan: enable networkingMode=mirrored in .wslconfig and re-measure, before vs after, (a) the TCP connect-timeout rate (SYN unanswered for ~30 s) to the run-actions-*-azure-eastus hosts from inside WSL2, and (b) the per-message acquirejob 100 s timeout rate on the runner. We'll also check reachability from a second WSL2 distro as you suggested. Since that change restarts WSL and the host runs other services, we'll do it in a maintenance window and report the before/after numbers here. If the connect timeouts clear with mirrored networking, that points at WSL2/NAT; if they persist on a clean path, it's the separate "re-offer after client timeout" case.

    Happy to keep sharing redacted _diag excerpts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions