freenet-core
freenet-core copied to clipboard
Implement Retry Logic for Update Propagation
Implement Retry Logic for Update Propagation
Overview
This PR implements retry logic for update propagation to improve reliability in networks where peers are not directly connected. The changes address the update propagation issues observed in the live Freenet network, particularly in applications like River where users cannot join rooms reliably.
Implementation Details
-
Added retry logic for update broadcasting with exponential backoff:
MAX_RETRIES=10- Same as the subscription systemBASE_DELAY_MS=100- Start with a small delayMAX_DELAY_MS=5000- Cap the maximum delay to 5 seconds
-
Modified the update state machine to handle retries:
- Added
RetryingBroadcaststate to track failed peers and retry count - Added retry_count to existing states for consistency
- Implemented exponential backoff with capped maximum delay
- Added
-
Changed error handling for failed broadcasts:
- Instead of dropping connections on failure, track failed peers for retry
- Retry broadcasting to failed peers with exponential backoff
- Only drop connections after maximum retries are exhausted
Key Features
- No Slowdown for Happy Path: The retry logic only activates when broadcasts fail, ensuring that successful updates are not delayed
- Exponential Backoff: Delays increase exponentially (BASE_DELAY_MS * 2^retry_count) but are capped at MAX_DELAY_MS
- Comprehensive Logging: Added detailed logging of retry attempts and success/failure status
Testing
The implementation has been tested with the peer blocking tests created in PR #1592 and #1593, which simulate a network where peers are connected through a gateway but not directly to each other.
Related Issues
This PR addresses the update propagation issues identified in PR #1592 and #1593, where updates fail to propagate reliably between indirectly connected peers.
Link to Devin run
https://app.devin.ai/sessions/d77861025c92420e8806849f463924ef
Requested by: Ian Clarke ([email protected])
🤖 Devin AI Engineer
I'll be helping with this pull request! Here's what you should know:
✅ I will automatically:
- Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
- Look at CI failures and help fix them
Note: I can only respond to comments from users who have write access to this repository.
⚙️ Control Options:
- [ ] Disable automatic comment and CI monitoring
rebase on main
Closing old debugging PR from devin-ai-integration as requested.