diff --git a/libs/cluster/Session/ClusterSession.cs b/libs/cluster/Session/ClusterSession.cs index 11253d644a..a75a16c634 100644 --- a/libs/cluster/Session/ClusterSession.cs +++ b/libs/cluster/Session/ClusterSession.cs @@ -79,7 +79,7 @@ public void ProcessClusterCommands(RespCommand command, ref SessionParseState pa { csvi.keyNumOffset = -1; clusterProvider.ExtractKeySpecs(commandInfo, command, ref parseState, ref csvi); - if (NetworkMultiKeySlotVerify(ref parseState, ref csvi, ref this.dcurr, ref this.dend)) + if (NetworkMultiKeySlotVerifyNoResponse(ref parseState, ref csvi, ref this.dcurr, ref this.dend)) return; } diff --git a/libs/cluster/Session/SlotVerification/RespClusterSlotVerify.cs b/libs/cluster/Session/SlotVerification/RespClusterSlotVerify.cs index 056c7232c9..591a38ee1d 100644 --- a/libs/cluster/Session/SlotVerification/RespClusterSlotVerify.cs +++ b/libs/cluster/Session/SlotVerification/RespClusterSlotVerify.cs @@ -110,6 +110,14 @@ public bool NetworkKeyArraySlotVerify(Span keys, bool readOnly, byte s return true; } + /// + /// Verify multi-key slot ownership + /// + /// + /// + /// + /// + /// public unsafe bool NetworkMultiKeySlotVerify(ref SessionParseState parseState, ref ClusterSlotVerificationInput csvi, ref byte* dcurr, ref byte* dend) { // If cluster is not enabled or a transaction is running skip slot check @@ -124,5 +132,24 @@ public unsafe bool NetworkMultiKeySlotVerify(ref SessionParseState parseState, r WriteClusterSlotVerificationMessage(config, vres, ref dcurr, ref dend); return true; } + + /// + /// Verify multi-key slot ownership without generating a response + /// + /// + /// + /// + /// + /// + public unsafe bool NetworkMultiKeySlotVerifyNoResponse(ref SessionParseState parseState, ref ClusterSlotVerificationInput csvi, ref byte* dcurr, ref byte* dend) + { + // If cluster is not enabled or a transaction is running skip slot check + if (!clusterProvider.serverOptions.EnableCluster || txnManager.state == TxnState.Running) return false; + + var config = clusterProvider.clusterManager.CurrentConfig; + var vres = MultiKeySlotVerify(config, ref parseState, ref csvi); + + return vres.state == SlotVerifiedState.OK ? false : true; + } } } \ No newline at end of file diff --git a/libs/server/Cluster/IClusterSession.cs b/libs/server/Cluster/IClusterSession.cs index a7f76a8807..9e23d4b375 100644 --- a/libs/server/Cluster/IClusterSession.cs +++ b/libs/server/Cluster/IClusterSession.cs @@ -88,6 +88,16 @@ public interface IClusterSession /// unsafe bool NetworkMultiKeySlotVerify(ref SessionParseState parseState, ref ClusterSlotVerificationInput csvi, ref byte* dcurr, ref byte* dend); + /// + /// Array slot verify with no response + /// + /// + /// + /// + /// + /// + unsafe bool NetworkMultiKeySlotVerifyNoResponse(ref SessionParseState parseState, ref ClusterSlotVerificationInput csvi, ref byte* dcurr, ref byte* dend); + /// /// Sets the user currently authenticated in this session (used for permission checks) ///