Skip to content

feat(scheduling): add soft task and group concurrency - #17

Merged
psteinroe merged 3 commits into
mainfrom
feat/soft-concurrency
Sep 18, 2026
Merged

psteinroe merged 3 commits into
mainfrom
feat/soft-concurrency

Conversation

@psteinroe

@psteinroe psteinroe commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Replace hard concurrency slots with database-coordinated soft task and group limits.

Workers count active executions while claiming with FOR UPDATE SKIP LOCKED. Concurrent claim transactions may temporarily overshoot a configured limit; no slot or semaphore rows are maintained. groupConcurrency applies independently within each populated (queue, task, group) scope, while ungrouped work bypasses the group limit.

Claim performance

The claim path now follows the bounded candidate pattern used by pg-boss, Graphile Worker, River, and Oban: it locks an ordered batch before applying task/group window ranking, instead of ranking the entire ready backlog. It materializes active executions once, skips saturated tasks and groups before locking, and uses a database-derived no-limit fast path so rolling workers cannot bypass newly configured limits. A covering partial index supports both task and group active counts.

With 1,000,000 ready executions and a batch size of 50, median claim latency dropped from 6,138 ms to 45 ms without limits, from 5,570 ms to 48 ms with a saturated group, and from 5,333 ms to 35 ms with a saturated task. A hot group can intentionally underfill one claim because ranking is bounded; the next poll excludes the now-saturated group and continues through eligible work.

Related consistency changes:

  • stale or unregistered orchestrators in the in-memory client release normal executions and fail cancelled executions;
  • settlement identifies a claimed execution by (id, queue, locked_by) without requiring the duplicated task key;
  • cron conflict updates refresh schedule payload, run time, cron expression, and group metadata.

Closes #12

@psteinroe
psteinroe added this pull request to stack #25 September 15, 2026 03:35
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch 10 times, most recently from 534b688 to 7e3838b Compare September 15, 2026 05:02
@psteinroe
psteinroe removed this pull request from stack #25 September 15, 2026 11:41
@psteinroe psteinroe changed the title feat(scheduling): add soft group concurrency feat(scheduling): add soft task and group concurrency Sep 15, 2026
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch 2 times, most recently from fe8c04a to d9847c5 Compare September 15, 2026 13:26
@psteinroe
psteinroe added this pull request to stack #27 September 15, 2026 13:27
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch from d9847c5 to 57e3d55 Compare September 15, 2026 13:41
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch from 57e3d55 to f6fa04a Compare September 15, 2026 13:43
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch 4 times, most recently from 276b56d to dceeb87 Compare September 15, 2026 14:06
Base automatically changed from feat/new-minor to main September 17, 2026 20:08
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch 4 times, most recently from 22c50bd to 59ca720 Compare September 18, 2026 09:32
@psteinroe
psteinroe force-pushed the feat/soft-concurrency branch from 59ca720 to a127ed3 Compare September 18, 2026 12:06
@psteinroe
psteinroe merged commit 3f2cf9a into main Sep 18, 2026
9 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.

Soft Task and Group Concurrency

1 participant