Commit e54ce53
authored
* fix: release gate reservation on retry to prevent queue wedge (#311)
The queue-gate reservation stored in RedisSortedSetFlow.activeReleases was
released only by resultWorker (terminal results). The retry path (retryWorker)
re-enqueued the request without releasing, so every retry leaked a reservation:
inFlight ratcheted up until Budget() reached 0 and the queue stopped dispatching
entirely (LocalConcurrencyGate, no TTL), or the redis-quota counter over-admitted
when its key TTL reset while requests were still in flight.
- retryWorker now releases each retried request's reservation before re-enqueue
(a re-dispatched request re-reserves via gate.Apply), ordered before
flushRetryBatch's ZAdd so the reservation cannot be overwritten/orphaned.
- Dispatch-time store uses sync.Map.Swap and releases any prior closure
defensively, so a lingering reservation is never orphaned.
- Add a regression test for the retry->release path (previously untested, which
is why the leak stayed latent).
Pub/Sub is unaffected: it holds the reservation in a function-scoped defer that
runs on every return path including Nack/retry.
Closes #311
Signed-off-by: Shimi Bandiel <shimib@google.com>
* docs(release-notes): add fragment for #334 (gate reservation leak fix)
Signed-off-by: Shimi Bandiel <shimib@google.com>
---------
Signed-off-by: Shimi Bandiel <shimib@google.com>
1 parent 68b46e8 commit e54ce53
3 files changed
Lines changed: 84 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
528 | 534 | | |
529 | 535 | | |
530 | 536 | | |
| |||
572 | 578 | | |
573 | 579 | | |
574 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
575 | 598 | | |
576 | 599 | | |
577 | 600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
498 | 551 | | |
499 | 552 | | |
500 | 553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments