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

transport-manager: Unknown connection opened #172

Closed
2 tasks done
Tracked by #140
lexnv opened this issue Jul 9, 2024 · 2 comments · Fixed by #179
Closed
2 tasks done
Tracked by #140

transport-manager: Unknown connection opened #172

lexnv opened this issue Jul 9, 2024 · 2 comments · Fixed by #179
Assignees
Labels
bug Something isn't working

Comments

@lexnv
Copy link
Collaborator

lexnv commented Jul 9, 2024

Investigate the following errors:

    "2024-07-06 04:53:54.449  WARN tokio-runtime-worker litep2p::transport-manager: unknown connection opened as secondary connection, discarding peer=PeerId(\"12D3KooWB9DVNyi6TQUhHeyq4LyBLVykybXUmcNmEUD9tcKEaYq1\") connection_id=ConnectionId(246958) address=\"/ip6/*/tcp/51326/ws/p2p/12D3KooWB9DVNyi6TQUhHeyq4LyBLVykybXUmcNmEUD9tcKEaYq1\" dial_record=AddressRecord { score: 100, address: \"/ip4/1*/tcp/31334/ws/p2p/12D3KooWB9DVNyi6TQUhHeyq4LyBLVykybXUmcNmEUD9tcKEaYq1\", connection_id: Some(ConnectionId(246946)) }",
    "2024-07-06 04:53:54.450  WARN tokio-runtime-worker litep2p::transport-manager: non-primary connection was closed but secondary connection doesn't exist peer=PeerId(\"12D3KooWB9DVNyi6TQUhHeyq4LyBLVykybXUmcNmEUD9tcKEaYq1\") connection_id=ConnectionId(246958)",
    "2024-07-06 04:53:54.450 ERROR tokio-runtime-worker litep2p::transport-manager: failed to handle closed connection error=InvalidState",
    "2024-07-06 04:54:04.058  WARN tokio-runtime-worker litep2p::transport-manager: non-primary connection was closed but secondary connection doesn't exist peer=PeerId(\"12D3KooWB9DVNyi6TQUhHeyq4LyBLVykybXUmcNmEUD9tcKEaYq1\") connection_id=ConnectionId(246953)",
    "2024-07-06 04:54:04.058 ERROR tokio-runtime-worker litep2p::transport-manager: failed to handle closed connection error=InvalidState",

Data collected from a long running litep2p substrate node in kusama

Tasks

  1. lexnv
  2. lexnv
@lexnv lexnv added the bug Something isn't working label Jul 9, 2024
@altonen
Copy link
Contributor

altonen commented Jul 9, 2024

The issue could be that after receiving an unknown unknown connection, TransportManager wants to discard it:

Some(record) => tracing::warn!(
target: LOG_TARGET,
?peer,
connection_id = ?endpoint.connection_id(),
address = ?endpoint.address(),
dial_record = ?record,
"unknown connection opened as secondary connection, discarding",
),

but that branch actually doesn't return early with ConnectionEstablishedResult::Reject but instead drops down to the default case at the end of the function which returns ConnectionEstablishedResult::Accept for all cases. This would explain why later on when the connection is closed, TransportManager doesn't recognize it.

@lexnv
Copy link
Collaborator Author

lexnv commented Jul 17, 2024

Its been a tricky edge-case, will keep an eye for triaging since we might have other minor gaps causing this state reset

Detailed repro case

  • T0: Dial address A connection ID 1 -> State : Dialing { in-flight-1 }
  • T1: Connection is established by remote address C connection ID 3 -> State : Connected { in-flight-dial 1 }
  • T2: Closed connection established in T2 -> State : Disconnected { in-flight-dial 1}

// This is where the state was wrongfully overwritten

  • T3: Dial address B connection ID 2 -> State: Dialing { in-flight-2 }

  • T4: Connection is established by remote address C connection ID 3 -> State : Connected { in-flight-dial 2 }

// The issue was detected here

  • T5: Dial from T0 receives a response however it expects in-flight-dial 1 and the state has in-flight-dial 2

@lexnv lexnv self-assigned this Jul 17, 2024
lexnv added a commit that referenced this issue Jul 31, 2024
…#176)

This PR ensures that the transport manager rejects secondary
connections.

When the secondary connection is rejected, the internal `dial_record` is
preserved.

Added a test to validate this behavior, with multiple wrong endpoints.

Part of: #172
Will keep the issue opened for to further into it. 

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv closed this as completed in #179 Aug 2, 2024
@lexnv lexnv closed this as completed in 7befb3a Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants