feat(sdk,core,webapp,run-engine): runtime override for the combined queue concurrency limit - #4829
feat(sdk,core,webapp,run-engine): runtime override for the combined queue concurrency limit#4829matt-aitken wants to merge 13 commits into
Conversation
🦋 Changeset detectedLatest commit: 43c724e The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Observability mapAs of 19/100 over 456 measured of 474 entry points (base 20, down 1) What this PR changed
FIX FIRST
AUDIT 3 of 50 sensitive mutations record an actor. 47 without one. What the score is made ofThe score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md. |
fbd79d2 to
5110870
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
5110870 to
fe1f3a4
Compare
2e8db3a to
eba7d2a
Compare
eba7d2a to
0f83715
Compare
0f83715 to
0bef7b3
Compare
0bef7b3 to
f103a5e
Compare
8ba16f9 to
9800b6a
Compare
da92e21 to
6b14574
Compare
6b14574 to
c227170
Compare
Sparse ckLimits HASH at the base queue whose fields are the exact ck-variant queue names, plus engine methods to set (atomic cardinality cap, default 1000 per queue), remove, and read the overrides. The admit-path gate wiring follows.
The ck dequeue admit and both enqueue fast paths read the queue's ckLimits HASH for the variant being admitted and use the env-clamped override in place of the queue's per-key limit, behind the totalConcurrencyEnabled flag. Covered by tests for lowered and raised keys, removal, the cardinality cap, and flag-off behavior.
Three nullable TaskQueue columns record when, by whom, and from what declared base the total concurrency limit was overridden, and a new TaskQueueConcurrencyKeyOverride child table stores per-key limit overrides, unique per queue and key and cascading with the queue.
queues.overrideConcurrencyLimit accepts a named concurrencyKey to adjust one key's limit independently, and new overrideTotalConcurrencyLimit and resetTotalConcurrencyLimit calls adjust the cap across all keys. Four API routes back them; the concurrency system validates against the environment limit, captures the declared base on first override, persists per-key overrides in the child table alongside the engine hash, and deploys keep an overridden total instead of clobbering it from the manifest.
…ked keys A variant blocked at its per-key limit or by a gate now backs off in the candidate index instead of pinning the bounded window, so zero-limit keys can never starve runnable keys behind them; acks and nacks rebalance the score back the moment capacity frees. Override writes persist before enforcing and resets enforce before clearing, so a failure on either side leaves a state a retry converges from, with the cap-rejected row compensated away. Deploys restore per-key overrides from their durable rows into the engine, and an empty concurrencyKey in the SDK no longer falls through to the queue-wide endpoint.
…en races Gate capacity now reads the gate queue's ckLimits hash, so an override on a key applies whether runs meet it as their own queue or as a gate. A reset deletes only the exact row generation it read, so a concurrent override's newer record survives, and a cap rejection deletes its row unconditionally since the cap can only reject keys absent from the engine hash.
…fe cap cleanup Gate admission reads a per-key override only when concurrency limit enforcement is enabled, matching the primary admit paths (the flag now threads through the unkeyed enqueue and dequeue scripts too). The cap-rejection cleanup deletes only the exact row generation the rejected request wrote, so a concurrent request that succeeded after capacity freed keeps its durable record.
The client build's export analyzer cannot statically resolve destructured route exports, so it treats the module's exports as depending on server-only code and the build fails. Also export the builder's loader so non-POST methods get a 405, matching the other concurrency routes.
The override and reset endpoints, client methods and SDK functions now say combinedConcurrencyLimit, matching the queue option.
…limit overrides Per-key runtime overrides are deferred: composing a per-key hash with pause semantics and keeping it convergent with durable rows across deploys and resets needs its own design. Combined-limit overrides stay. Declared per-key behavior is unchanged (concurrencyLimit applies per key as before).
Removes the per-key override endpoints, the override-aware admit and gauge reads, and the per-key limit column, following the removal of runtime per-key overrides from this stack.
…remain The per-key admit reads are removed in the PR above alongside the rest of the engine-internal plumbing; the key builders they reference stay until then so every level of the stack compiles.
c227170 to
43c724e
Compare
Summary
Adjust a queue's combined concurrency limit at runtime without a deploy.
queues.overrideCombinedConcurrencyLimitraises or lowers the cap on concurrent runs across all of a queue'sconcurrencyKeyvalues, andqueues.resetCombinedConcurrencyLimitreverts to the declared configuration. Stacked on #4827.Design
Combined overrides follow the existing override bookkeeping exactly: validated against the environment limit, the declared base captured on first override, reset restoring it, and deploys preserving an active override instead of clobbering it from the code manifest (the declared value lands in the base). The read path clamps to the environment limit at admit time.
Per-key runtime overrides were built in earlier revisions of this PR and then deliberately removed: composing a per-key override hash with pause semantics and keeping it convergent with durable rows across deploys, resets, and races needs its own design, so that feature is deferred to a future PR. Declared per-key behavior is unchanged (
concurrencyLimitapplies per key as before).