Skip to content

Implement Retry Logic for Update Propagation #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

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 (ian.clarke@gmail.com)

Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Copy link
Contributor Author

🤖 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

devin-ai-integration bot and others added 16 commits May 12, 2025 23:57
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
… direct send

Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
…riesReached

Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
Co-Authored-By: Ian Clarke <github@ian.33mail.com>
@sanity sanity marked this pull request as draft May 13, 2025 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants