Feature: Add Queue Multiplexing Scheduler#398
Draft
sephynox wants to merge 2 commits into
Draft
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit df577aa. Configure here.
|
Member
|
Should this still be in draft? It doesn't look finished because it lacks working implementations for all drivers. |
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.




Summary
Deployments with tens of thousands of routes run one poll loop per runner, issuing O(routes x partitions) queries per tick against mostly empty partitions. This PR adds a single-loop scheduler that scans the backend for partitions with actionable work and runs only their owning units, activating them on demand and deactivating them when idle.
Note
Medium Risk
Touches core queue storage, runner pipe maintenance, and an automatic Postgres schema migration; scheduler misconfiguration or scan bugs could skip or hot-loop work at scale, though behavior is heavily test-covered.
Overview
Adds a single-loop
KeetaAnchorQueueSchedulerthat discovers partitions with actionable work via one backend scan, wakes owning schedulable units (notify, fast pass, recovery sweeps, idle deactivate), and caps per-iteration work so large backlogs do not starve other heads.Introduces optional
scanActivePathson queue storage (withKeetaAnchorQueueScanFilter) on the memory driver and PostgreSQL (plus driver tests for memory/file/postgres); Redis/SQLite/Firestore do not implement it yet. Postgres gets schema version 3 with a(status, path)index to support status-first scans, and path-prefixLIKEescaping for segments containing%/_.Centralizes partition keys via
EncodeQueuePath/ValidateQueuePartitionSegment(.in segment names rejected) across drivers. Failed stage moves now refreshupdatedwithout changing status/failures so time-bounded sweeps keep retrying pipes; batch idempotent conflicts refresh stranded members similarly.New
scheduler.test.tsand expanded queue tests cover scan behavior, partition validation, and move-refresh semantics.Reviewed by Cursor Bugbot for commit 783c4bc. Bugbot is set up for automated code reviews on this repo. Configure here.