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

fix(hole-punch): don't explicitly close RESERVE stream #4747

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

Making a reservation on a relay involves a request-response protocol. First we send the RESERVE message and then we receive the relay's response. After we've received the response, we have all the information we need and the reservation is valid.

It appears that on QUIC, closing the stream can fail if the other party also closed the stream already. This can result in the entire operation failing at the very end even though everything else has succeeded.

There is no reason to explicitly close the stream as the remote is not going to read from it beyond the first message anyway. The fact that we receive a response means the remote read our request.

This should resolve some of the flakiness that we've been seeing with the hole-punch interop tests.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@thomaseizinger thomaseizinger added send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer. labels Oct 27, 2023
@thomaseizinger
Copy link
Contributor Author

@mxinden Please feel free to weigh in with your opinion on this. Based on the above reasoning, I don't think this is particularly controversial, hence I am moving forward with this so that I can update the test-plans repository which in turn should resolve the flakiness we've been seeing in the other PRs.

@thomaseizinger
Copy link
Contributor Author

@mxinden I don't think it matters whether we drop the stream or close it properly. If we wanted to close it properly, we could do so directly after sending the message perhaps?

@mergify mergify bot merged commit 461209a into master Oct 27, 2023
71 checks passed
@mergify mergify bot deleted the feat/no-close-stream branch October 27, 2023 06:00
@mxinden
Copy link
Member

mxinden commented Oct 29, 2023

It appears that on QUIC, closing the stream can fail if the other party also closed the stream already.

I thought we fixed this in the past when still using quinn-proto and I thought moving to quinn directly did so as well. #3164

Instead of a fix at the libp2p-relay level, I think this requires a fix at the libp2p-quic layer.

If we wanted to close it properly, we could do so directly after sending the message perhaps?

In my eyes that would be the right thing to do, i.e. close right after writing the reservation request, before reading the reservation response.

@thomaseizinger
Copy link
Contributor Author

It appears that on QUIC, closing the stream can fail if the other party also closed the stream already.

I thought we fixed this in the past when still using quinn-proto and I thought moving to quinn directly did so as well. #3164

Instead of a fix at the libp2p-relay level, I think this requires a fix at the libp2p-quic layer.

Agreed that this needs to be the permanent fix. I'll try to reproduce it using a test in quinn.

If we wanted to close it properly, we could do so directly after sending the message perhaps?

In my eyes that would be the right thing to do, i.e. close right after writing the reservation request, before reading the reservation response.

We can reintroduce that once it doesn't cause flaky tests. It doesn't make a difference for the protocol itself though :)

@thomaseizinger
Copy link
Contributor Author

I opened a PR: quinn-rs/quinn#1699.

mergify bot pushed a commit that referenced this pull request Nov 2, 2023
Not explicitly closing a stream can lead to stream resets in the happy path once the stream is dropped. Instead, explicitly close the stream once the local node is done sending data.

Related: #4747.

Pull-Request: #4776.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants