Skip to content

Commit 1b24915

Browse files
committed
docs(run-engine): state what the lease signal actually guarantees
The in-flight member is keyed only by message and queue id, so once another consumer re-claims a reclaimed item the member exists again and an extend from the previous consumer succeeds. The signal therefore only catches the window where the item is back on the queue and unclaimed, which is narrower than the comment and the changeset claimed.
1 parent ff348c4 commit 1b24915

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

.changeset/fair-queue-concurrency-slot-leak.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
"@trigger.dev/redis-worker": patch
33
---
44

5-
Fair queue consumers no longer leak concurrency slots. A slot is now always released when a message completes or is put back on the queue, even when its in-flight record has already gone. Leaked slots were never reclaimed, so enough of them would permanently stall every queue belonging to that tenant.
5+
Fair queue consumers no longer leak the concurrency slots that gate a tenant's throughput. Slots were held by messages that had already finished, were never reclaimed, and once enough of them accumulated every queue belonging to that tenant stopped being served. Slots are now freed on the paths that previously skipped them, freed before the record needed to recover them is discarded, and released before a reclaimed message goes back on the queue. A failed release is now surfaced instead of being silently treated as success.
6+
7+
Concurrency groups keyed on queue metadata rather than the tenant can still resolve to the wrong group when a consumer completes a message it did not enqueue, so this does not yet cover that case.

internal-packages/run-engine/src/batch-queue/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,14 @@ export class BatchQueue {
761761
// ============================================================================
762762

763763
/**
764-
* Keep extending a message's visibility deadline while its callback runs, and return a
765-
* function that stops doing so. Without this an item slower than the visibility timeout
766-
* is redelivered while still being processed, and the original consumer's completion
767-
* then destroys the redelivery's in-flight record, silently dropping the item and
768-
* leaving the batch short of its expected count forever.
764+
* Keep extending a message's visibility deadline while its callback runs, so an item
765+
* slower than the visibility timeout is not redelivered and executed a second time.
766+
*
767+
* `lostLease` reports that an extend found no in-flight entry, which means the item was
768+
* reclaimed and is now back on the queue. It is a best-effort signal, not a fence: the
769+
* in-flight member is keyed only by message and queue id, so once another consumer
770+
* re-claims the item the member exists again and an extend from this consumer succeeds.
771+
* Distinguishing owners would need a per-claim token in the member.
769772
*/
770773
#startHeartbeat(
771774
messageId: string,

0 commit comments

Comments
 (0)