-
Notifications
You must be signed in to change notification settings - Fork 179
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
feat: avoid duplicate autoconnection attempt #1742
feat: avoid duplicate autoconnection attempt #1742
Conversation
Gossip autoconnection could result in two nodes attempting to connect to each other concurrently. To fix this issue, only one node initiate the connection now. The selection criteria is arbitrary but deterministic, currently the greater zid of both.
if !self.autoconnect.is_empty() | ||
&& self.autoconnect.matches(whatami) | ||
&& select_autoconnect_node(self.graph[self.idx].zid, zid) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a more complex problem than what it seems. Consider the following:
- Node1 is a peer, it is setup to autoconnect to routers and peers.
- Node2 is a router, it is setup to autoconnect only to routers.
- Node2 has a higher ZID, and therefore is the one returned by
select_autoconnect_node
.
In thise case, Node1 will not attempt to connect because it is not the selected node, and Node2 will not autoconnect because it does not have peers in its autoconnect config, and the connection will never be established...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we add autoconnect config to the exchanged gossip information, the other solutions may involve closing one of the two links during or after opening the transport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos and missing comments
Co-authored-by: Oussama Teffahi <[email protected]>
Co-authored-by: Oussama Teffahi <[email protected]>
Co-authored-by: Oussama Teffahi <[email protected]>
/// (e.g. autoconnect_strategy : { "to-router": "always", "to-peer": "greater-zid" }), | ||
/// or different values for router or peer mode | ||
/// (e.g. autoconnect_strategy : { peer: { "to-router": "always", "to-peer": "greater-zid" } }). | ||
autoconnect_strategy: { peer: { "to-router": "always", "to-peer": "always" } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add the default config for router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no default autoconnection for router, I could put the one for peer though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever the current behavior is should be the default, I assume it's "always" for all cases
/// (e.g. autoconnect_strategy : { "to-router": "always", "to-peer": "greater-zid" }), | ||
/// or different values for router or peer mode | ||
/// (e.g. autoconnect_strategy : { peer: { "to-router": "always", "to-peer": "greater-zid" } }). | ||
autoconnect_strategy: { peer: { "to-router": "always", "to-peer": "always" } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add the default config for router
Gossip autoconnection could result in two nodes attempting to connect to each other concurrently.
To fix this issue, only one node initiate the connection now. The selection criteria is arbitrary but deterministic, currently the greater zid of both.