replace assert with if check to avoid crash when connection is not open #55
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 envoy the upstream connection creation is an asynchronous process , where the connection initiation is done as part of code flow , but it doesn't wait for connection completion (TCP 3 Way handshake). This has been the design of envoy from day 1 . where if the connection timeout , it will be intimated to downstream clients and clients has to retry
the current code flow checks for socket creation before buffering request until connection is established, as socket creation has to be immediate it was not considered a problem.
in some rare occasions where the socket creation takes time, the make request method may be hit even before the socket is created , current code handles this by assertion . But since assertion causes envoy restart, we need to fix it
this kind of race condition is likely to happen for pubsub implementation as opposed to regular command handling because, pubsub always ends in creating connections where regular commands use clients in pool
the fix is to avoid the assert and return error for clients to retry