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

[skip changelog] fix: Drop stream references on Close/Reset #760

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

MarcoPolo
Copy link
Contributor

Lets connections get GC'd sooner (possibly before the streamMessageSender is GC'd)

There's a small extension to this pr in https://github.com/ipfs/boxo/tree/marco/with-AfterFunc that uses context.AfterFunc. But even without that, from my tests, this seems to help as well.

@MarcoPolo MarcoPolo requested a review from a team as a code owner December 16, 2024 23:05
Copy link

welcome bot commented Dec 16, 2024

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 79.41176% with 7 lines in your changes missing coverage. Please review.

Project coverage is 60.51%. Comparing base (2a5c7d0) to head (af8522d).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
bitswap/network/ipfs_impl.go 79.41% 5 Missing and 2 partials ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #760      +/-   ##
==========================================
+ Coverage   60.43%   60.51%   +0.07%     
==========================================
  Files         245      245              
  Lines       31102    31126      +24     
==========================================
+ Hits        18797    18836      +39     
+ Misses      10630    10619      -11     
+ Partials     1675     1671       -4     
Files with missing lines Coverage Δ
bitswap/network/ipfs_impl.go 79.12% <79.41%> (-2.57%) ⬇️

... and 8 files with indirect coverage changes

Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

What is the motivation for this? I'm not sure streams are Closed/Reset at all much, so maybe that's the real problem.

I am not sure the code needs to be concurrency-safe either. Does it? The messagequeue seems to SendMessage sequentially.

bitswap/network/ipfs_impl.go Show resolved Hide resolved
@MarcoPolo
Copy link
Contributor Author

I am not sure the code needs to be concurrency-safe either. Does it? The messagequeue seems to SendMessage sequentially.

Correct. It's necessary if we use the AfterFunc as in this change (which was a small diff on this): https://github.com/ipfs/boxo/pull/763/files. Let me change this to remove that and move the atomic to that PR.

@gammazero
Copy link
Contributor

gammazero commented Dec 18, 2024

@MarcoPolo Thank you. IMO we will want both PRs anyway since it seems like we would want to nil the connection if the context was canceled anyway. That way we have a better chance of reconnecting before using the dead connection instead of getting an error while using it.

@MarcoPolo
Copy link
Contributor Author

Makes sense. I just tidied up this PR by moving the atomic things to the next PR.

@gammazero gammazero force-pushed the marco/drop-stream-reference branch from cc5f567 to 9acb9f9 Compare December 18, 2024 20:52
MarcoPolo and others added 2 commits December 18, 2024 11:10
Lets connections get GC'd sooner (possibly before the
streamMessageSender is GC'd)
refactor: if the conn has a context, use context.AfterFunc for cleanup
---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
@gammazero gammazero force-pushed the marco/drop-stream-reference branch from 9acb9f9 to af8522d Compare December 18, 2024 21:11
@gammazero gammazero merged commit 3a844a9 into main Dec 18, 2024
15 checks passed
@gammazero gammazero deleted the marco/drop-stream-reference branch December 18, 2024 22:52
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