Skip to content

P2P: Fix duplicate connection logic #1255

@heifner

Description

@heifner

See #1243 for additional info.

The current scheme still leaves duplicates in some race conditions. A simpler approach was recently attempted. See #1108. However, this approach had a race condition so that it would sometimes disconnect both connections; reverted in #1186. The issue is that the connection and handshake messages can be sent from each node at the same time. Both nodes can consider the other a duplicate at the same time and both disconnect.

We believe the race condition can be solved using the following technique.

  1. On disconnect because of duplicate connection, do not attempt an immediate retry of the connections.
  2. When connecting to a peer, verify there is not already a open connection to that peer node_id.
    a. Note the node_id of the connection must be saved on close to make this determination.
  3. Maintain the logic of closing a duplicate if node's node_id less than peer node_id.

Metadata

Metadata

Assignees

Labels

OCIWork exclusive to OCI teambugThe product is not working as was intended.👍 lgtm

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions