Skip to content
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

Reuse sync client5x #165

Merged
merged 1 commit into from
Mar 8, 2024
Merged

Reuse sync client5x #165

merged 1 commit into from
Mar 8, 2024

Conversation

gammazero
Copy link
Collaborator

@gammazero gammazero commented Mar 8, 2024

Reuse sync client unless peer addresses changed

A new sync client was being created for each advertisement that entries were synced for. This was not a problem for plain HTTP since the HTTP client was reused. However for libp2phttp a new namespaced client was created each time. This established another connection between the indexer and the index-provider. Long advertisement chains could eat up all network resources and cause indexing to grind to a halt.

This PR fixes this by reusing each index-provider's sync client to sync advertisement chains and entries chains. A sync client is kept with the index-provider dagsync subscription handler. A new sync client is created only if there is no sync client yet or if the index-provider's addresses have changed.

A new sync client was being created for each advertisement that entries were synced for. This was not a problem for plain HTTP since the HTTP client was reused. However for libp2phttp a new namespaced client was created each time. This established another connection between the indexer and the index-provider. Long advertisement chains could eat up all network resources and cause indexing to grind to a halt.

This PR fixes this by reusing each index-provider's sync client to sync advertisement chains and entries chains. A sync client is kept with the index-provider dagsync subscription handler. A new sync client is created only if there is no sync client yet or if the index-provider's addresses have changed.
Copy link
Member

@masih masih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch thanks @gammazero 🍻

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 88.40580% with 8 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (ad-sequence-num-0.5.x@d416513). Click here to learn what that means.

Files Patch % Lines
dagsync/subscriber.go 75.86% 6 Missing and 1 partial ⚠️
dagsync/ipnisync/sync.go 91.66% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                   Coverage Diff                    @@
##             ad-sequence-num-0.5.x     #165   +/-   ##
========================================================
  Coverage                         ?   53.66%           
========================================================
  Files                            ?       68           
  Lines                            ?     5763           
  Branches                         ?        0           
========================================================
  Hits                             ?     3093           
  Misses                           ?     2339           
  Partials                         ?      331           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gammazero gammazero changed the base branch from ad-sequence-num-0.5.x to release-v0.5.x March 8, 2024 11:15
@gammazero gammazero merged commit a85b8f9 into release-v0.5.x Mar 8, 2024
8 checks passed
@gammazero gammazero deleted the reuse-sync-client5x branch March 8, 2024 11:17
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.

3 participants