Skip to content

feat: orchestration and table optimisations - #32

Merged
JohnDuprey merged 3 commits into
mainfrom
dev
Aug 11, 2026
Merged

feat: orchestration and table optimisations#32
JohnDuprey merged 3 commits into
mainfrom
dev

Conversation

@Zacgoose

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and optimizations to the orchestration and storage layers, focusing on job queue efficiency, key safety for Azure Table storage, and server-side filtering for better scalability. The most significant changes include implementing exponential backoff for idle job queue polling, adding server-side filtering to reduce unnecessary data transfer, and introducing a utility for sanitizing table keys to prevent backend errors.

Job Queue Efficiency and Polling Improvements:

  • Added exponential backoff to the JobQueuePump polling interval when the queue is idle, using a new _idlePollInterval and a doubling strategy to reduce unnecessary polling and backend load during idle periods. The delay resets when work appears, ensuring responsiveness. (Services/Orchestration/JobQueuePump.cs [1] [2] [3] [4] [5]

Azure Table Storage Key Safety:

  • Introduced the TableKeys utility class to sanitize partition and row keys for Azure Table storage, replacing illegal characters with underscores to prevent persistent backend errors. This is now used when generating task IDs for storage. (Services/Storage/TableKeys.cs [1] Services/Orchestration/OrchestratorService.cs [2] [3]

Server-side Filtering and Storage Optimization:

  • Added support for OData $filter expressions in QueryTableAsync for Azure Table storage, allowing server-side filtering of claimable jobs. The filter is used in the job claim path to avoid paging the entire backlog to the client, significantly improving efficiency for large queues. (Services/Storage/ICraftTableStore.cs [1] Services/Storage/AzureTableStore.cs [2] Services/Storage/JobQueueStore.cs [3] [4]

Testing and Validation:

  • Added a new integration test to verify that the server-side filter for claimable jobs correctly returns only free and expired rows, ensuring that live (leased) jobs are not erroneously reclaimed. (tests/Craft.Tests/JobQueueAzuriteTests.cs tests/Craft.Tests/JobQueueAzuriteTests.csR65-R96)

Push job-claim filtering down into table queries so the pump only scans claimable rows instead of paging the full backlog on each tick. Add exponential idle poll backoff that resets whenever the pump claims or still holds work, preventing unnecessary storage scans without throttling active queue throughput. Includes Azurite coverage for the server-side filter and new pump backoff regression tests.
Add a shared `TableKeys` utility to detect and sanitize Azure Table-invalid key characters, then apply it when minting orchestrator task IDs before uniqueness checks. This prevents permanent enqueue 400s caused by names like `Owner/Repo` and preserves distinct tasks when lossy sanitization would otherwise collide. Includes focused tests for illegal characters, control chars, safe-pass behavior, repo-name task IDs, collision handling, and queue row-key safety.
Add a shared server-side RunName filter for run-scoped queue operations so cleanup, lease release, and queued-id lookups stop scanning the entire table. This preserves existing client-side checks for correctness while reducing storage load, and adds Azurite coverage to verify cross-run isolation and quoted run names.
@Zacgoose
Zacgoose requested a review from JohnDuprey August 11, 2026 16:37
@JohnDuprey
JohnDuprey merged commit 4e30faf into main Aug 11, 2026
7 checks passed
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