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

swarm: fix swarm closed connection count #2115

Closed
wants to merge 1 commit into from

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Feb 18, 2023

fixes: #2113

@sukunrt sukunrt changed the title fix swarm closed connection count swarm: fix swarm closed connection count Feb 18, 2023
@sukunrt sukunrt force-pushed the fix-swarm-conn-count branch from e44b6c8 to f91d706 Compare February 18, 2023 06:07
@sukunrt sukunrt marked this pull request as ready for review February 18, 2023 06:46
@marten-seemann
Copy link
Contributor

Nice debugging! Why did you decide to not move the OpenedConnection call to addConn?

@sukunrt
Copy link
Member Author

sukunrt commented Feb 19, 2023

I chose this because if we moved OpenedConnection to swarm.addConn we'd not track connections dropped here
I thought this tracking of concurrent successful dials and some of them immediately dropped might be useful if we change something in the future.
A fix I thought of was to drain w.resch here but that didn't look very clean.

@MarcoPolo
Copy link
Collaborator

Nice work! Let me also say that I'm sorry the dial logic is a bit messy.

While I think this PR is reasonable, I'm afraid it still misses some close cases e.g.. I think the strategy should be to make sure we make fewer calls not more, since more is an indicator that this is brittle and requires us to remember to make the right calls when things error or close. My suggestion then is to make sure we record this metric in the .Close() call itself. This is good for two reasons: 1. Less duplication – we can just reuse the existing Close calls to record the metric, and 2. If we notice this number being wrong we can be pretty sure that there's a connection leak issue rather than us forgetting to call this metric.

Since we're on a time crunch I'm going to push a PR with these changes. But thanks for this PR and debugging this, it helped me at least :)

@sukunrt
Copy link
Member Author

sukunrt commented Feb 23, 2023

I'm afraid it still misses some close cases e.g..

oops

I agree. My PR has ClosedConnection calls all over the place. your change looks much cleaner. Thanks for fixing this :)

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.

swarm metrics: connection counting seems broken
3 participants