freenet-core icon indicating copy to clipboard operation
freenet-core copied to clipboard

Implement Retry Logic for Update Propagation

Open devin-ai-integration[bot] opened this issue 6 months ago • 2 comments
trafficstars

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

  1. Added retry logic for update broadcasting with exponential backoff:

    • MAX_RETRIES=10 - Same as the subscription system
    • BASE_DELAY_MS=100 - Start with a small delay
    • MAX_DELAY_MS=5000 - Cap the maximum delay to 5 seconds
  2. Modified the update state machine to handle retries:

    • Added RetryingBroadcast state to track failed peers and retry count
    • Added retry_count to existing states for consistency
    • Implemented exponential backoff with capped maximum delay
  3. 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

iduartgomez avatar May 16 '25 11:05 iduartgomez

Closing old debugging PR from devin-ai-integration as requested.

sanity avatar Jul 16 '25 00:07 sanity