Skip to content

Feature: Add Queue Multiplexing Scheduler#398

Draft
sephynox wants to merge 2 commits into
mainfrom
feat/queues-multiplexer-scheduler
Draft

Feature: Add Queue Multiplexing Scheduler#398
sephynox wants to merge 2 commits into
mainfrom
feat/queues-multiplexer-scheduler

Conversation

@sephynox

@sephynox sephynox commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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 KeetaAnchorQueueScheduler that 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 scanActivePaths on queue storage (with KeetaAnchorQueueScanFilter) 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-prefix LIKE escaping for segments containing %/_.

Centralizes partition keys via EncodeQueuePath / ValidateQueuePartitionSegment (. in segment names rejected) across drivers. Failed stage moves now refresh updated without changing status/failures so time-bounded sweeps keep retrying pipes; batch idempotent conflicts refresh stranded members similarly.

New scheduler.test.ts and 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.

@sephynox sephynox requested a review from ezraripps July 10, 2026 04:16
@sephynox sephynox self-assigned this Jul 10, 2026
@sephynox sephynox added the enhancement New feature or request label Jul 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ 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.

Comment thread src/lib/queue/index.ts
Comment thread src/lib/queue/scheduler.ts
Comment thread src/lib/queue/scheduler.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@rkeene

rkeene commented Jul 10, 2026

Copy link
Copy Markdown
Member

Should this still be in draft? It doesn't look finished because it lacks working implementations for all drivers.

@sephynox sephynox marked this pull request as draft July 10, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants