redis_proxy: allow custom commands within transactions#45958
Open
Kasamix wants to merge 2 commits into
Open
Conversation
Commands configured via custom_commands are registered with the simple command handler and work as standalone commands, but were rejected with "'<command>' command is not supported within transaction" when used inside a MULTI/EXEC transaction, because TransactionRequest::create() only checked the static transaction/simple/multi-key command sets. Plumb the configured custom commands into TransactionRequest::create() via a dedicated transaction command handler factory, and accept them within transactions, treating them as simple commands to match their behavior outside of transactions. Fixes envoyproxy#42094 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Kasamix <giangdavid2004@gmail.com>
|
Hi @Kasamix, 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. |
Declare custom_commands_ adjacent to transaction_handler_ (its only user) rather than at the top of the member list, restoring the original constructor initializer wrapping. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Kasamix <giangdavid2004@gmail.com>
Contributor
|
/gemini review |
Contributor
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
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.
Commit Message: redis_proxy: allow custom commands within transactions
Commands configured via :ref:
custom_commandsare registered with the simple command handler and work as standalone commands, but were rejected with'<command>' command is not supported within transactionwhen used inside a MULTI/EXEC transaction, becauseTransactionRequest::create()only checked the static transaction/simple/multi-key command sets. This PR plumbs the configured custom commands intoTransactionRequest::create()via a dedicated transaction command handler factory, and accepts them within transactions, treating them as simple commands to match their behavior outside of transactions.Additional Description:
The command splitter already treats custom commands as simple commands for standalone execution (
InstanceImplregisters them with the simple command handler). When a transaction is active, however, all commands are routed to the transaction handler, whoseTransactionRequest::create()had no knowledge of the configured custom commands and rejected them. The fix introduces a smallTransactionCommandHandlerFactorythat holds a reference to the configuredcustom_commandsset and passes it toTransactionRequest::create(), where it is consulted alongside the existing simple/multi-key command set checks. Custom commands inside transactions get the same treatment as simple commands, including the caveat that already applies to multi-key commands in transactions (keys must map to the same upstream).No runtime guard was added: the change only affects commands explicitly opted in via
custom_commands, and only inside transactions, where they previously always failed with a hard error.Disclosure per the generative AI policy: this change was developed with the assistance of generative AI (Claude Code by Anthropic).
Risk Level: Low — a small bug fix; only affects commands explicitly configured via
custom_commands, and only within MULTI/EXEC transactions, where such commands previously always returned an error.Testing:
command_splitter_impl_test.cc: custom command forwarded within an active transaction; custom command as the first command of a transaction (MULTI sent upstream first); regression test that a supported-but-not-simple command (scan) is still rejected within a transaction (this rejection path previously had no coverage).PipelinedTransactionWithCustomCommandwith acustom_commands-enabled config, reproducing the scenario from the issue (MULTI →json.set→ EXEC) end to end.//test/extensions/filters/network/redis_proxy/...and//test/extensions/filters/network/common/redis/...pass locally (macOS arm64). The new tests were verified to fail without the source change.Docs Changes: Updated the Transactions section of the Redis architecture overview (
docs/root/intro/arch_overview/other_protocols/redis.rst) to document that configured custom commands are supported within transactions and treated as single-key commands.Release Notes:
changelogs/current/bug_fixes/redis_proxy__custom-commands-in-transactions.rstPlatform Specific Features: N/A
Fixes #42094