Add pre-fetch quota check for JetStream Sensor backpressure#13
Merged
abdulazillow merged 9 commits intofeature/zgfrom Jan 15, 2026
Merged
Add pre-fetch quota check for JetStream Sensor backpressure#13abdulazillow merged 9 commits intofeature/zgfrom
abdulazillow merged 9 commits intofeature/zgfrom
Conversation
- Add BackpressureWaiter to check ResourceQuota before fetching from JetStream - Integrate into trigger_conn.go pullSubscribe loop - Add sensor_quota_blocked metric - Add env var configuration (BACKPRESSURE_QUOTA_NAME, etc.) - Add implementation documentation This prevents message loss when NATS connection is lost during extended backpressure periods (quota full for hours).
TODO: Remove [BACKPRESSURE-TEST] logs after verification complete
- Add setupBackpressure() helper called from both initial and reconnect paths - Add closeCh check after WaitForCapacity to catch close signals during poll
Collaborator
|
Thanks, was able to verify that the fix is working. |
dhanashritidke11
approved these changes
Jan 15, 2026
Collaborator
dhanashritidke11
left a comment
There was a problem hiding this comment.
LGTM, Approved
talebzeghmi
approved these changes
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add pre-fetch quota check for JetStream Sensor backpressure
Description
Implements pre-fetch quota check for JetStream Sensor to prevent message loss during resource quota exhaustion. When downstream workflow quota is near capacity, the sensor blocks before fetching messages from JetStream, keeping them safely in durable storage.
Problem: When ResourceQuota is full for extended periods, messages held in sensor memory during retries can be lost if the NATS connection drops (orphaned ACK bug).
Solution: Check ResourceQuota capacity before fetching messages from JetStream. Messages stay in durable storage until there's capacity to process them.
Configuration
env:
value: "workflow-quota"
value: "0.95"
value: "30"### New Metric
argo_events_sensor_quota_blocked- Gauge: 1 when blocked, 0 when processing normallyTesting
Unit Tests: Added
backpressure_test.gocovering:HasCapacity()threshold calculationsWaitForCapacity()blocking and context cancellationIntegration Testing:
sensor_quota_blockedmetric toggles correctlyLong-Running Test:
Additional Fixes
setupBackpressure()helper called from both initial connection and reconnection pathscloseChcheck afterWaitForCapacity()to handle connection drops during blockingBackward Compatibility
✅ Fully backward compatible - Backpressure is disabled by default (requires
BACKPRESSURE_QUOTA_NAMEenv var)