Revert "derive crypto before opening TCP stream" #2459
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In further testing, this introduces too much reordering under high concurrency for our dedup tracking to mitigate. connect() can "complete" in reverse order of starts (e.g., due to queueing of the wake events) which leads to huge gaps (up to concurrency) in the chosen key IDs.
We can likely get the best of both worlds by deriving crypto beforehand but only associating it with a stream just-in-time as connect()s complete (keeping a per-peer pool just for opening connections) but that's a more invasive change, for now just revert this.
This reverts commit 71e56fe (#2451).
Testing:
This was caught in a more thorough integration test. I think it's likely possible to simulate that within a unit-ish test (TCP connect to localhost or so), but it feels a bit artificial to write it directly. In any case, that can come in a separate PR since this is just a revert.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.