Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dinesh-murugiah
Copy link
Collaborator

@dinesh-murugiah dinesh-murugiah commented Oct 10, 2025

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a potential crash in the Redis client implementation by replacing an assertion with graceful error handling. The change addresses a race condition where the makePubSubRequest method could be called before the connection is fully established, which would previously cause Envoy to restart due to an assertion failure.

Key changes:

  • Replaces assertion with conditional check and error handling in makePubSubRequest
  • Adds error logging when connection is not open
  • Returns false to allow clients to retry instead of crashing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


bool ClientImpl::makePubSubRequest(const RespValue& request) {
ASSERT(connection_->state() == Network::Connection::State::Open);
//ASSERT(connection_->state() == Network::Connection::State::Open);
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

Remove the commented-out assertion code instead of leaving it in place. Commented-out code should not remain in the codebase as it can cause confusion and clutter.

Suggested change
//ASSERT(connection_->state() == Network::Connection::State::Open);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@Sasidharan-Gopal Sasidharan-Gopal left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants