Fix BITOP failures in MULTI/EXEC transactions (#1954)#1966
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes BITOP failures when executed inside MULTI/EXEC by aligning the transaction validation + key-locking logic with the fact that BITOP consumes its operation token (AND/OR/XOR/NOT/DIFF) during parsing (similar to the existing cluster slot verification handling). It also adds regression tests for the two reported transactional failure modes.
Changes:
- Treat normalized
BITOPas “subcommand-like” during transaction queue-time arity validation (NetworkSKIP). - Thread an explicit
isSubCommandflag into transaction key locking so key-spec indices are resolved with the correct offset forBITOP. - Add two regression tests covering
BITOP NOTandBITOP ANDinside a transaction.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/standalone/Garnet.test.complexstring/GarnetBitmapTests.cs | Adds regression tests for BITOP behavior inside MULTI/EXEC. |
| libs/server/Transaction/TxnRespCommands.cs | Adjusts transaction queue-time arity validation and passes subcommand-offset intent to key locking for BITOP. |
| libs/server/Transaction/TxnKeyManager.cs | Updates key-locking API to accept an explicit “resolve as subcommand” flag and forwards it to key-spec resolution. |
kevin-montrose
approved these changes
Jul 22, 2026
kevin-montrose
self-requested a review
July 22, 2026 18:54
kevin-montrose
approved these changes
Jul 22, 2026
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.
Description
Fixes #1954 —
BITOPcommands fail insideMULTI/EXECtransactions.BITOPis parsed as a subcommand-style command: the operation token (AND/OR/XOR/NOT/DIFF) is consumed by the parser, soparseStatestarts at the destination key. However, its command metadata (Arity = -4, key-spec indices2/3) describes the flat form where the operation token is still present, andNormalizeForACLsmapsBITOP_*to the parentBITOP(whoseIsSubCommandisfalse). The transaction path never accounted for the consumed token, causing two failures:BITOP NOT→EXECABORT: the queue-time arity check inNetworkSKIPcomputed a minimum of 3 args instead of 2, wrongly rejecting the validBITOP NOT dst src(2 args).BITOP AND(binary ops) → transactional-lock assert:LockKeysresolved key-spec indices without the subcommand offset, so the destination key was neverXLocked (Attempting to use a non-XLocked key in a Transactional context).Fix
Apply the same BITOP special-case already used by cluster slot verification (
RespServerSessionSlotVerify.cs) to the transaction path:TxnRespCommands.NetworkSKIP: treatcmd == RespCommand.BITOPas a subcommand when computing arity, and pass the flag through to key locking.TxnKeyManager.LockKeys: accept an explicitisSubCommandand forward it toTryGetKeySearchArgsFromSimpleKeySpec, which already applies the correct-2key-index offset.Tests
Added the two repro tests from the issue (
BitopNotTransactionAsync,BitopAndTransactionAsync) toGarnetBitmapTests. Both fail without the fix and pass with it.