Repository navigation
Conversation
|
Results from running this patch on two self-hosted runners (v2.337.0 + this change, Linux x64), swapped in at 2026-09-19 09:53Z. Before (stock 2.337.0): After (patched): 0 The only change between the two periods is this patch. Marking ready for review. |
2f1e849 to
0f83fdb
Compare
7a4af2f to
95b52ee
Compare
|
This patch also worked for me, thanks @osazemeu! |
95b52ee to
964126e
Compare
OnJobStatus cancelled the in-flight GetMessages poll on every status change. On the Busy to Online transition at job completion, the service can assign the next queued job and deliver it on that still-open Busy poll; aborting the request dropped the message, and the redelivery arrived after the assignment expired (acquirejob 409 MissingKey), so the job was eventually cancelled as "not acquired by Runner". An Online status is now recorded and sent on the next poll without aborting the open one. A Busy transition still cancels as before. Applied to both BrokerMessageListener and MessageListener. Fixes actions#4728.
964126e to
b20eabd
Compare
|
you're welcome @inslayn 🥳 |
|
Hi maintainers, could someone review this PR and let us know whether anything else is needed before it can be merged? The author reported zero MissingKey errors across 349 jobs after applying the patch, and @inslayn also confirmed it worked for them. Thanks for taking a look! |
|
Data point from a production fleet: 40 persistent, repo-scoped Linux x64 runners. In a canary on our repository, the official build lost 13.4 % of jobs with "The job was not acquired by Runner". With the poll kept open on Busy -> Online in |
Leaving the Busy poll open until it ended on its own kept the runner reported as Busy, and the service does not offer jobs to a Busy runner, so the ~61 s gap moved instead of disappearing. On Online, cancel the poll after 3 s: a job assigned at completion still arrives on it, and the next poll reports Online.
…nto keep-busy-poll-open-on-online
Fixes #4728.
When a job completes,
OnJobStatuscancels the openGET /message?status=Busypoll so the next poll reportsOnline. The service assigns the next queued job at that moment and delivers it on the Busy poll, so the abort drops the message. The redelivery arrives after the assignment expires (acquirejob409MissingKey) and the job is eventually cancelled as "not acquired by Runner".The first commit keeps the poll open on the transition to
Online(_runnerStatusis still updated and sent on the next poll). It is the change running in production, see below. The second commit replaces that with a 3 s grace period and is the unverified part of this PR.Grace commit: on the transition to
Online, the open poll is cancelled after a 3 s grace period (CancelAfter) instead of at once. A job the service assigns at completion still arrives on that poll, and the next poll reportsOnlineabout 3 s later. The transition toBusystill cancels immediately, as before.Why a grace at all: @dsmirnoff73 reported on #4728 that on 2.338.2 (ARM64, 8 runners on one host) the first commit left an idle runner waiting about 61 s, because the open poll keeps reporting
Busy, and that a 3 s grace removed the wait. That does not reproduce on six org-scoped x64 runners running the first commit: 322 jobs queued within 55 s of a completion were all acknowledged within 5 s (2026-10-31 to 2026-11-07), andMissingKeywas 15 across all runners from 2026-10-01 to 2026-11-07. The grace commit is kept as a draft until CI and a canary run agree, and can be dropped if the first commit is enough.Applied to both
BrokerMessageListenerandMessageListener, which share the pattern. Each poll has its own token source, disposed infinally, so a pending timer cannot cancel a later poll.Tests
OnJobStatus_OnlineGivesInFlightPollAGracePeriod_BusyCancelsItin bothBrokerMessageListenerL0andMessageListenerL0. The mocked poll stays open until the test answers it or its token is cancelled. The test checks that:Onlinestatus event leaves the in-flight Busy poll uncancelled at first;Online;Busystatus event still cancels the in-flight poll at once, and the re-issued poll returns its message fromGetNextMessageAsync.Grace commit not yet run locally: the .NET 8.0.425 SDK pinned in
global.jsonis not installed on the author's machine, so CI is the first run of the grace-period version.Not covered
acquirejobtiming out after 100 s and then getting 409MissingKeyon the retry (reported from WSL2 in #4728). That is a separate path from this race and is not changed here.Feature flag
Not added. The
Featuresflags inConstants.csreach the runner in job messages, andOnJobStatusruns between jobs, so there is no flag the listener could read at this point.