fix: Fix out-of-order responses in manual transactions with commands before MULTI#4441
Open
fix: Fix out-of-order responses in manual transactions with commands before MULTI#4441
Conversation
…commands Fixes out-of-order response issues when using manual transactions (doMulti=false) mixed with commands executed outside the transaction. Root Cause: When commands are executed on a Transaction before multi() is called, they were being queued as pipelined commands instead of executed immediately. This caused responses to be out of order when exec() was later called. Changes: - Modified Transaction.appendCommand() to check inMulti flag - Commands before multi() are now executed immediately via executeCommand() - Commands after multi() are queued as before (pipelined) - Added Response.DecodedResponse inner class to wrap immediate results - Added Response.of() and Response.error() factory methods for creating pre-decoded responses This ensures commands before multi() get immediate responses while maintaining proper transaction semantics for commands after multi(). Verified by: RedisClientTransactionIT.transactionManualWithCommandsBeforeMulti ✅
Test Results 304 files + 1 304 suites +1 12m 11s ⏱️ +27s Results for commit e6626c5. ± Comparison against base commit cd75d78. This pull request removes 10 and adds 24 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
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.
PR Title
PR Description
Problem
When using manual transactions (
doMulti=false) and executing commands before callingmulti(), responses were returned out of order. This occurred because all commands were being queued as pipelined commands, regardless of whether the transaction had started.Solution
Modified
Transaction.appendCommand()to check theinMultiflag:multi(): Commands are executed immediately and wrapped inResponse.DecodedResponsemulti(): Commands are queued as pipelined commands (existing behavior)This ensures commands before the transaction get immediate responses while maintaining proper transaction semantics for commands within the transaction block.
Changes
Core Changes
Transaction.appendCommand(): AddedinMultiflag check to determine execution strategy (execute immediately vs queue in transaction)Transaction.execute(): New private method to execute commands immediatelyResponse.DecodedResponse: New inner class to wrap pre-decoded responsesResponse.of()/Response.error(): Factory methods for creating decoded responsesTesting
RedisClientTransactionIT.transactionManualWithCommandsBeforeMulti()validates the fixBackward Compatibility
✅ No breaking changes
✅ Existing transaction behavior unchanged
✅ Only affects manual transactions with commands before
multi()