Repository navigation
Implement redis blocking command - #42823
Closed
Sasidharan3094 wants to merge 2 commits into
Closed
Sasidharan3094 wants to merge 2 commits into
Sasidharan3094 wants to merge 2 commits into
Conversation
Signed-off-by: Sasidharan Gopal <[email protected]>
Signed-off-by: Sasidharan Gopal <[email protected]>
|
Hi @Sasidharan3094, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
dinesh-murugiah
left a comment
Contributor
There was a problem hiding this comment.
Request to hold this until pub sub client implemtation where we will have a clean abstraction for creating clients
| const RouteSharedPtr& route, const std::string& command, const std::string& key, | ||
| Common::Redis::RespValueConstSharedPtr incoming_request, ConnPool::PoolCallbacks& callbacks, | ||
| Common::Redis::Client::Transaction& transaction) { | ||
| Common::Redis::Client::Transaction& transaction, bool is_blocking_command = false) { |
Contributor
There was a problem hiding this comment.
passing a bool here doesnt look elegant , we need to have a clean design which is inclusive of accomodating other type of cliuents
Contributor
|
@Sasidharan-Gopal request to close this PR , better to colloborate in my fork to handle both pubsub and blocking client to avoid repetitive changes |
Author
|
Closing this for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add Support for Redis Blocking Commands (BLPOP)
Summary
This PR implements support for Redis blocking commands, starting with BLPOP (Blocking List Pop). The implementation uses an
is_blocking_clientflag pattern to bypass Envoy's operation timeout for blocking commands, allowing them to wait longer than the configuredop_timeoutwithout causing connection failures.Problem
Redis blocking commands like BLPOP can have timeouts that exceed Envoy's configured
op_timeout. For example:BLPOP mylist 6(6 second timeout)op_timeout: 5sconfiguredSolution
Implemented an
is_blocking_clientflag (similar to the existingis_transaction_clientpattern) that:is_blocking_commandparameterArchitecture
Request Flow
Key Components
1. Command Registration (
supported_commands.h/cc)blockingCommands()set containing "blpop"isBlockingCommand()helper methodwriteCommands()set2. Client Interface (
client.h,client_impl.h/cc)setBlockingClient(bool)method to Client interfaceis_blocking_client_member variable to ClientImplmakeRequest(): Skip timeout when making blocking requestonEvent(): Skip timeout when connection establishesonRespValue(): Skip timeout when handling responses + auto-reset flag3. Connection Pool (
conn_pool.h,conn_pool_impl.h/cc)is_blocking_commandparameter to all request methodsclient->setBlockingClient(true)before making blocking requests4. Command Splitter (
command_splitter_impl.h/cc)BlockingRequestclass for timeout validationSupportedCommands::isBlockingCommand()for routingis_blocking_command=truethrough request chainDesign Decisions
Per-Request Flag: Flag is set per-request and auto-resets, allowing same connection to handle both blocking and non-blocking commands
Three-Point Protection: Timeout checks at request initiation, connection establishment, and response handling ensure complete coverage
Extensible Architecture: Uses
isBlockingCommand()check instead of hardcoding command names, making it trivial to add BRPOP, BRPOPLPUSH, etc.Transaction Compatible: Works with both regular clients and transaction clients
Mirror Safety: Mirror requests always use
is_blocking_command=falseTesting
Manual Testing
Files Modified
Core Implementation
source/extensions/filters/network/common/redis/supported_commands.h- Command registrationsource/extensions/filters/network/common/redis/supported_commands.cc- Command validationsource/extensions/filters/network/common/redis/client.h- Client interfacesource/extensions/filters/network/common/redis/client_impl.h- Client implementation headersource/extensions/filters/network/common/redis/client_impl.cc- Timeout bypass logicConnection Pool
source/extensions/filters/network/redis_proxy/conn_pool.h- Pool interfacesource/extensions/filters/network/redis_proxy/conn_pool_impl.h- Pool implementation headersource/extensions/filters/network/redis_proxy/conn_pool_impl.cc- Flag propagationCommand Handling
source/extensions/filters/network/redis_proxy/command_splitter_impl.h- BlockingRequest classsource/extensions/filters/network/redis_proxy/command_splitter_impl.cc- Request validationDocumentation
BLPOP_IMPLEMENTATION_SUMMARY.md- Comprehensive implementation guideBenefits
op_timeoutto accommodate blocking commandsFuture Enhancements
Adding new blocking commands is straightforward:
blockingCommands()set insupported_commands.hwriteCommands()if it modifies stateCommands that can be added using the same pattern:
Backward Compatibility
Risk Assessment
Low Risk
is_transaction_clientpatternblockingCommands()set