Repository navigation
feat(orchestrator): Sweep again without waiting while work is overdue - #426
Open
morgan-wowk wants to merge 1 commit into
Open
morgan-wowk wants to merge 1 commit into
morgan-wowk wants to merge 1 commit into
Conversation
process_each_queue_once now returns whether the next sweep should start right away: a queued execution was launched, or a pending or running container execution was last refreshed longer ago than the new internal _running_execution_refresh_interval (30s). run_loop skips its sleep in that case, so a backlog of running executions is refreshed back to back instead of one per second. An idle or caught-up orchestrator still sleeps between sweeps, and so does one whose queue handler raised.
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.
Problem
run_loopsleepssleep_seconds_between_queue_sweepsafter every sweep, and each sweep visits at most one running container execution. With hundreds of active container executions, a single pass over the running queue takes minutes, and that time is mostly spent sleeping. A container that finished waits that long before its status lands.Changes
process_each_queue_once()now returns whether the next sweep should start without waiting. It returnsTruewhen either:_running_execution_refresh_intervalago (new internal kwarg, default 30s). This is oneEXISTSquery.run_loopskips its sleep when the sweep returnsTrue.System impact
Production test
All three orchestrator PRs ran together in production as patches (https://github.com/Shopify/oasis-backend/pull/843). Before/after:
This PR is the same change built into
OrchestratorService_Sqlinstead of being patched in.Related PRs
process_each_queue_once()(its heartbeat call vs this return). The conflict is trivial: call the heartbeat, then return.Testing
pytest tests: 587 passed.tests/test_orchestrator_sweep_pacing.pycovers: