Skip to content

feat(orchestrator): poll builds and stop the ones nothing wants - #504

Merged
behinddwalls merged 1 commit into
mainfrom
preetam/speculation-buildsignal-paths
Aug 7, 2026
Merged

feat(orchestrator): poll builds and stop the ones nothing wants#504
behinddwalls merged 1 commit into
mainfrom
preetam/speculation-buildsignal-paths

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

The poll loop was writing the path set on every terminal build — the third concurrent writer on a row where the speculate run, which holds a version across its whole Speculator call, was structurally the one to lose. And with the build stage now start-only, something has to enact cancellation.

What?

The poll loop becomes speculation's kill mechanism. On every poll of a non-terminal build it checks whether anything still wants the build running — batch not halted, the path's entry live and on this build's attempt, the attempt's link naming this very build — and asks the runner to cancel when nothing does. That one level-triggered check subsumes path cancels, batch halts, superseded attempts, and lost dispatch races: no cancel message exists to go stale, and a check that misses one poll is remade on the next.

It cannot cancel a wanted build: every "unwanted" condition is permanent once true, so a stale read only errs toward keeping, and store anomalies (a set, entry, or link that cannot legitimately be missing) also keep the build — a cancel is irreversible. The Cancel call is best-effort so a failure never kills the poll chain that would retry it. The path set is read as that kill list and never written.

Polls now partition on the build ID rather than the batch, and each re-poll mints a distinct message ID so the queue never dedups it away. The halted short-circuit stays removed: a cancelling batch reaches terminal only once its builds stop, and this loop is both what stops them and what watches them stop.

Test Plan

bazel test //submitqueue/orchestrator/... — every unwanted condition cancels; a wanted build never sees a Cancel; anomalies keep the build; a failed Cancel does not fail the poll; statuses recorded per terminal state; and no path-set write happens at all (the set store is wired read-only on the mock).

make fmt, make gazelle

Issues

@behinddwalls
behinddwalls marked this pull request as ready for review August 4, 2026 01:53
@behinddwalls
behinddwalls requested review from a team and sbalabanov as code owners August 4, 2026 01:53
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 9cd7353 to 7ff20d4 Compare August 4, 2026 01:58
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from c2d441b to 37428c4 Compare August 4, 2026 01:58
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 37428c4 to c33a2d6 Compare August 4, 2026 05:11
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch 2 times, most recently from 2e32d07 to e37f128 Compare August 5, 2026 03:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from c33a2d6 to 6cabb60 Compare August 5, 2026 03:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from e37f128 to 70285fb Compare August 5, 2026 03:26
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 6cabb60 to 8a077b1 Compare August 5, 2026 03:26
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 70285fb to 3983b14 Compare August 5, 2026 03:38
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 8a077b1 to 492d1cb Compare August 5, 2026 03:38
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 3983b14 to 57dcb4f Compare August 5, 2026 03:43
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 492d1cb to 65aad34 Compare August 5, 2026 03:43
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 57dcb4f to 125e288 Compare August 5, 2026 04:11
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 65aad34 to 3e3666f Compare August 5, 2026 04:11
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 125e288 to f41ca0f Compare August 5, 2026 04:57
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 3e3666f to 7f2f2fe Compare August 5, 2026 04:57
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch 2 times, most recently from 246145c to b2a17a5 Compare August 5, 2026 17:28
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from d870cb4 to 5658532 Compare August 5, 2026 17:28
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from b2a17a5 to bf0df7a Compare August 5, 2026 19:05
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch 2 times, most recently from d6273e5 to 9ac443d Compare August 6, 2026 02:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from bf0df7a to a6b5f8d Compare August 6, 2026 02:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 9ac443d to a6435a5 Compare August 6, 2026 02:34
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from a6b5f8d to 60970f0 Compare August 6, 2026 02:34
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from a6435a5 to cf21443 Compare August 6, 2026 03:04
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 60970f0 to e780560 Compare August 6, 2026 03:04
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from cf21443 to 8d307b2 Compare August 6, 2026 03:17
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from e780560 to 4142ca7 Compare August 6, 2026 03:17
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 8d307b2 to 781562f Compare August 6, 2026 03:32
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 4142ca7 to bd68e1f Compare August 6, 2026 03:32
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from 781562f to c149f02 Compare August 7, 2026 03:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from bd68e1f to ae3dfa9 Compare August 7, 2026 03:15
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch from c149f02 to f2a2cbe Compare August 7, 2026 03:30
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from ae3dfa9 to c28713b Compare August 7, 2026 03:30
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from c28713b to 350d26d Compare August 7, 2026 19:48
@behinddwalls
behinddwalls force-pushed the preetam/speculation-build-dispatch branch 2 times, most recently from 031ab18 to 043f412 Compare August 7, 2026 19:54
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from 350d26d to ee4fcaa Compare August 7, 2026 19:54
## Summary

### Why?

The poll loop was writing the path set on every terminal build — the third concurrent writer on a row where the speculate run, which holds a version across its whole Speculator call, was structurally the one to lose. And with the build stage now start-only, something has to enact cancellation.

### What?

The poll loop becomes speculation's kill mechanism. On every poll of a non-terminal build it checks whether anything still wants the build running — batch not halted, the path's entry live and on this build's attempt, the attempt's link naming this very build — and asks the runner to cancel when nothing does. That one level-triggered check subsumes path cancels, batch halts, superseded attempts, and lost dispatch races: no cancel message exists to go stale, and a check that misses one poll is remade on the next.

It cannot cancel a wanted build: every "unwanted" condition is permanent once true, so a stale read only errs toward keeping, and store anomalies (a set, entry, or link that cannot legitimately be missing) also keep the build — a cancel is irreversible. The Cancel call is best-effort so a failure never kills the poll chain that would retry it. The path set is read as that kill list and never written.

Polls now partition on the build ID rather than the batch, and each re-poll mints a distinct message ID so the queue never dedups it away. The halted short-circuit stays removed: a cancelling batch reaches terminal only once its builds stop, and this loop is both what stops them and what watches them stop.

## Test Plan

✅ `bazel test //submitqueue/orchestrator/...` — every unwanted condition cancels; a wanted build never sees a Cancel; anomalies keep the build; a failed Cancel does not fail the poll; statuses recorded per terminal state; and no path-set write happens at all (the set store is wired read-only on the mock).

✅ `make fmt`, `make gazelle`

# Conflicts:
#	submitqueue/orchestrator/controller/buildsignal/BUILD.bazel
#	submitqueue/orchestrator/controller/buildsignal/buildsignal.go
#	submitqueue/orchestrator/controller/buildsignal/buildsignal_test.go

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto 5658532
# Last command done (1 command done):
#    pick 246145c # feat(orchestrator): poll builds and stop the ones nothing wants
# No commands remaining.
# You are currently rebasing branch 'preetam/speculation-buildsignal-paths' on '5658532b'.
#
# Changes to be committed:
#	modified:   submitqueue/orchestrator/controller/buildsignal/BUILD.bazel
#	modified:   submitqueue/orchestrator/controller/buildsignal/buildsignal.go
#	modified:   submitqueue/orchestrator/controller/buildsignal/buildsignal_test.go
#	modified:   submitqueue/orchestrator/controller/dlq/buildsignal.go
#	modified:   submitqueue/orchestrator/controller/dlq/buildsignal_test.go
#

# Conflicts:
#	submitqueue/orchestrator/controller/buildsignal/buildsignal.go
#	submitqueue/orchestrator/controller/buildsignal/buildsignal_test.go
#	submitqueue/orchestrator/controller/dlq/buildsignal.go
#	submitqueue/orchestrator/controller/dlq/buildsignal_test.go

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# interactive rebase in progress; onto 3db751f0
# Last command done (1 command done):
#    pick bd68e1f # feat(orchestrator): poll builds and stop the ones nothing wants
# No commands remaining.
# You are currently rebasing branch 'preetam/speculation-buildsignal-paths' on '3db751f0'.
#
# Changes to be committed:
#	modified:   submitqueue/orchestrator/controller/buildsignal/BUILD.bazel
#	modified:   submitqueue/orchestrator/controller/buildsignal/buildsignal.go
#	modified:   submitqueue/orchestrator/controller/buildsignal/buildsignal_test.go
#	modified:   submitqueue/orchestrator/controller/dlq/buildsignal.go
#	modified:   submitqueue/orchestrator/controller/dlq/buildsignal_test.go
#
@behinddwalls
behinddwalls changed the base branch from preetam/speculation-build-dispatch to main August 7, 2026 20:13
@behinddwalls
behinddwalls force-pushed the preetam/speculation-buildsignal-paths branch from ee4fcaa to 6331c0f Compare August 7, 2026 20:13
@behinddwalls
behinddwalls merged commit f031c98 into main Aug 7, 2026
12 of 25 checks passed
@behinddwalls
behinddwalls deleted the preetam/speculation-buildsignal-paths branch August 7, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants