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

Disconnect nodes in two steps in the full node #3050

Merged
merged 2 commits into from
Nov 30, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Nov 29, 2022

The full node currently can't really sync because the following happens repeatedly: we connect to a peer, start a request, then the peer disconnects us, and we cancel the request.

Why do peers disconnect us? Because they're actually full. Substrate unfortunately doesn't implement the networking protocol as was intended, and instead of refusing peers ahead of time if it is full, it accepts them then disconnects them. See paritytech/polkadot-sdk#556.

Due to the easy-to-use-but-prone-to-race-conditions API, it is not possible to know whether the request might already have a response at the time of the disconnect. If it already has a response, then canceling the request simply discards it, which is meh.
Also, peers might still answer our request even after disconnecting us. It is at their discretion. In fact, Substrate does this. "Disconnecting" in this context doesn't mean "closing the TCP connection" but "notifying that we don't want peering anymore". The TCP connection is only closed after 10 seconds of inactivity.

What this PR does is: when a peer disconnects, we don't cancel the requests that targeting this peer and that are still in progress. Instead, we simply stop sending any new request, and clean up that peer only once all of its requests are finished.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼──────────────────
          +0 ┊ Σ [0 Total Rows]

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Nov 30, 2022
@mergify mergify bot merged commit 7750c22 into paritytech:main Nov 30, 2022
@tomaka tomaka deleted the dc-in-two-steps branch November 30, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant