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

fix(connection-limits): correct connection tracking #4250

Merged
merged 15 commits into from
Jul 26, 2023

Conversation

AgeManning
Copy link
Contributor

@AgeManning AgeManning commented Jul 25, 2023

Description

The connection limit behaviour was not taking into account connection errors. Also, it was using the behaviour events to indicate established connections which is not always going to be the case because other behaviours can deny the connections (thanks @divagant-martian).

Closes #4249

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@AgeManning AgeManning changed the title fix(misc) Correct connection limit behaviour fix(misc): Correct connection limit behaviour Jul 25, 2023
@mxinden
Copy link
Member

mxinden commented Jul 26, 2023

Thank you @AgeManning. Reviewing right now. Will prioritize a patch release.

@mxinden
Copy link
Member

mxinden commented Jul 26, 2023

//CC @shamil-gadelshin as I think you have described seeing this bug in the last open maintainers call.

Comment on lines 329 to 330
self.pending_inbound_connections.remove(&connection_id);
self.pending_outbound_connections.remove(&connection_id);
Copy link
Member

Choose a reason for hiding this comment

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

@AgeManning are these two lines needed? A FromSwarm::ConnectionClosed should always be preceded by a handle_established_{outbound,inbound}_connection. In those methods we reduce the self.pending_*_connections counters.

Copy link
Member

Choose a reason for hiding this comment

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

Removed with 8167c71. Please still review @AgeManning.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this is fine to remove. Just being overly cautious

@mxinden
Copy link
Member

mxinden commented Jul 26, 2023

I pushed a couple of commits. Hope you don't mind @AgeManning. Any objections to the additional changes? If not, I will merge here and cut a patch release.

Again, thank you for the work @AgeManning and @divagant-martian.

@mxinden mxinden changed the title fix(misc): Correct connection limit behaviour fix(connection-limits): correct connection tracking Jul 26, 2023
Copy link
Contributor

@divagant-martian divagant-martian left a comment

Choose a reason for hiding this comment

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

Ty for the follow up changes @mxinden. To speed this up since it's late for @AgeManning I'm taking the lead on saying this looks good

mxinden
mxinden previously approved these changes Jul 26, 2023
misc/connection-limits/CHANGELOG.md Outdated Show resolved Hide resolved
misc/connection-limits/src/lib.rs Outdated Show resolved Hide resolved
@mxinden mxinden added send-it and removed send-it labels Jul 26, 2023
@mergify mergify bot dismissed mxinden’s stale review July 26, 2023 11:38

Approvals have been dismissed because the PR was updated after the send-it label was applied.

mxinden
mxinden previously approved these changes Jul 26, 2023
@mergify mergify bot dismissed mxinden’s stale review July 26, 2023 11:58

Approvals have been dismissed because the PR was updated after the send-it label was applied.

@divagant-martian
Copy link
Contributor

divagant-martian commented Jul 26, 2023

@mxinden just to bring your attention to the fact that mergify was not very fond of the merge commit

@mergify mergify bot merged commit 53df982 into libp2p:master Jul 26, 2023
64 of 66 checks passed
@mxinden
Copy link
Member

mxinden commented Jul 26, 2023

@mxinden just to bring your attention to mergify was not very fond of the merge commit

:/ Thanks! I think the root of the issue is, that only I have push access to https://github.com/sigp/, not all rust-libp2p maintainers (including mergify).

@mxinden
Copy link
Member

mxinden commented Jul 26, 2023

Tagged and published.

Thank you for the debugging and implementation work.

@AgeManning
Copy link
Contributor Author

Nice. Yeah I was sleeping, sorry. Looks like diva had us covered.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Thank you for the effort in debugging and fixing this!

thomaseizinger pushed a commit that referenced this pull request Aug 20, 2023
The connection limit behaviour was not taking into account connection errors. Also, it was using the behaviour events to indicate established connections which is not always going to be the case because other behaviours can deny the connections (thanks @divagant-martian).

Closes #4249

Pull-Request: #4250.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed outbound connections and connection limits
5 participants