Skip to content

Handle the situation that two nodes try to connect to each other simultaneously #724

@hyunsikjeong

Description

@hyunsikjeong

It happens in the discovery integration tests. You can reproduce the situation sometimes by running the tests.

If two nodes try to connect to each other at the same time, the routing table of each node set the other node to the establish state, by

if self.connections.connect(token, stream, local_node_id, session, socket_address, self.get_port()) {
    self.routing_table.establish(socket_address);
    Some(token)
}

Next, they sends Sync message to each other, and stuck. Also, you can find out an error message Cannot find session, because of the code below:

let session = self
    .routing_table
    .unestablished_session(&remote_addr)
    .ok_or(Error::General("Cannot find session"))?;

Notice that it is already established in the routing table.

Metadata

Metadata

Labels

bugSomething isn't workingnetwork

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions