Repository navigation
fix(pool): workers terminate when drained; idempotent drain; --cost-limit (#1146, #1183) - #1192
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Oct 19, 2026
scttfrdmn
force-pushed
the
fix/1146-1183-pool-lifecycle
branch
from
October 19, 2026 21:42
ba5e9a3 to
d4e2118
Compare
…le; truthful idle wording spawn app launch sets an 8h TTL when --ttl is not given and refuses an empty one (#1150). spawn service and pool workers set the new LaunchConfig.TerminateOnIdle (spawn:terminate-on-idle), so spored terminates them when idle instead of stopping them (#1151, refs #1146). Help and notices that said idle terminates on stop paths are corrected, and a gate walks the command tree for idle-terminate claims (#1132).
…-cost-limit Pool workers now write the completion record on a clean drain (and a failed one when they exhaust restarts), so on_complete=terminate fires. Worker.Run drains at once when its queue is deleted and honours its idle deadline on the claim-error path. Builds on #1200's TerminateOnIdle for spored's own idle action. pool drain reports 'already drained' and exits 0 on a missing queue. pool create gains a per-worker --cost-limit. Fixes #1146 Fixes #1183
scttfrdmn
force-pushed
the
fix/1146-1183-pool-lifecycle
branch
from
October 20, 2026 00:25
d4e2118 to
c1726f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pool workers now terminate when they run out of work,
pool drainis idempotent, andpool createtakes a per-worker--cost-limit. Owner decision on #1146: idle or drained workers terminate (not stop).Fixes #1146
Fixes #1183
Depends on #1200 (rebased onto
fix/1150-1151-app-service-lifecycle). Until #1200 merges, this PR's diff also shows its commit. #1200 adds spored's idle-terminate action (LaunchConfig.TerminateOnIdle) and sets it for pool workers inpoolWorkerBaseConfig. This PR builds on that rather than adding a second mechanism.What changed
buildPoolWorkerCommand): on a clean exit it writes the completion record to the file spored watches, soon_complete=terminatefires. A worker that hits its 20 restarts writes afailedrecord and terminates; before, it waited for the TTL.Worker.Run(pkg/taskpool/worker.go): aNonExistentQueueclaim error (queue deleted bypool drain) drains straight away, with no retry. A worker whose claims have all failed forIdleTimeoutdrains instead of retrying once a second until TTL. The claim-error backoff now goes through a seam, so tests count retries instead of sleeping.spored pool-worker: if the queue is already gone at open (for example a restart after drain), it exits 0 instead of entering the restart loop.poolWorkerBaseConfig): now also setsCompletionFile/CompletionDelayexplicitly (astask rundoes since task run: confirm on_complete=terminate fires (spored version + completion-file) — TTL is currently the only guaranteed teardown #406) andCostLimit. spored's idle timeout stays armed, with fix: app launch 8h default TTL; service and pool workers terminate on idle; truthful idle wording #1200'sTerminateOnIdle.pool drainuses the newtaskpool.DrainRun: oneGetQueueUrl. If the queue is missing it prints "already drained" and exits 0. Other errors still fail.Pool.Draindoc now describe the real behaviour. Also fixed the visibility-timeout comment from spawn pool: visibility-timeout comment, design-doc reconcile loop, unparseable spec acked with no record #1149 (same file, one line).taskpool.IsQueueGone,DrainRun,DrainRunWithConfig(additions only; snapshot regenerated).Gates (each watched failing against a revert that compiles)
TestWorker_QueueDeletedDrainsAtOnce: one ReceiveMessage, zero retries, nil returnif false && IsQueueGone(cerr)TestWorker_ClaimErrorsHonourTheIdleDeadline: counting sleep advances a fake clockif false && now().After(idleDeadline)TestDrainRun_Idempotent: second drain(true, nil)after exactly 1 GetQueueUrlif false && IsQueueGone(err)TestPoolWorkerCleanExitWritesTheCompletionRecord(runs the script with a stub spored) +TestPoolWorkerScriptWritesTheFileSporedWatches(anchored^\s*cat > "<CompletionFile>" <<JSONEOF$, tied to the launch config's CompletionFile)catto /dev/nullTestPoolCostLimitReachesTheWorkerLaunchConfig(set through the real flag)CostLimit:Also: #1200's
TestIdleTerminateClaimsAreTruenow seespool create --idle-timeout's new help ("Workers terminate after..."), sospawn pool createis added to itsidleTerminateProofs. The claim is true:TerminateOnIdleis set.TestPoolWorkerThatGivesUpWritesAFailedRecordruns the script with a failing stub spored and a no-opsleepon PATH. It is Linux-only, like the existing script tests.Checks
make check: every step passed exceptcheck-build-tags, which fails on the/private/tmpworktree path for untouchedtest/e2efiles (known on main).make check-docs: clean.semgrep --config=auto --error: clean.go test -raceon the touched packages: pass.Not verified
Not run on AWS. The
spored pool-workerqueue-gone-at-open path has no unit test: it sits behind provider/IMDS construction.