fix: improve backoff retry mechanism #859
Open
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.
Summary
This PR fixes issue #599 by improving the backoff retry mechanism in the TAP agent. The issue described that when a sender is denied, it aggregates too slowly since RAV requests are only triggered by
UpdateReceiptFees
messages after a fixedretry_interval
(~30 secs), making the aggregation process too slow when the aggregator is UP.Problem
As described in issue #599:
UpdateReceiptFees
messagesretry_interval
(~30 secs)Solution
Use backoff information to retry aggregating instead of a fixed retry_interval (as suggested in the issue):
Backoff System Improvements
BackoffInfo
: Replacedin_backoff()
withremaining()
method for more precise timing controlmin_remaining_backoff()
: New method inSenderFeeTracker
to get the minimum remaining backoff across all allocationsschedule_retry()
method that considers both global and allocation-specific backoff statesretry_interval
fromSenderAccountArgs
in favor of dynamic backoff-based schedulingTesting & Quality
retry_helpers_tests
module with tests for:BackoffInfo::remaining()
reset behavior after successful operationsSenderFeeTracker::min_remaining_backoff()
roundtrip functionalitytracker.rs
Technical Details
The retry mechanism now works as follows:
BackoffInfo
) and allocation-specific (SenderFeeTracker
) backoff states are updatednext_retry_delay()
method calculates the maximum of global and allocation-specific remaining backoff timesTesting
The new functionality has been tested with standalone tests that verify:
Files Modified
crates/tap-agent/src/agent/sender_account.rs
- Main retry logic improvementscrates/tap-agent/src/agent/sender_accounts_manager.rs
- Removed hardcoded retry intervalcrates/tap-agent/src/backoff.rs
- Enhanced backoff information trackingcrates/tap-agent/src/test.rs
- Added comprehensive unit testscrates/tap-agent/src/tracker.rs
- Added min_remaining_backoff method and fixed syntaxFixes
Closes #599