You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EVAL && EVALSHA commands infers wrong node by key hash slot on cluster mode.
Usage in abstract:
constsha=/** sha of script that get some key */constkeys=['1key']constargs=['arg1','arg2']awaitcluster.evalSha(sha,{
keys,arguments: args})
As of my understanding each command uses the FIRST_KEY_INDEX function that's defined in it's module and then based on that the node is inferred based on the hash slot of first key.
So, in essence what happens is that the evalFirstKeyIndex gets options as a list and it does not having a keys object in it. maybe the second item in the list will have. as in the scope of the extractFirstKey fn the originalArgs is actualy the input of original evalSha call.
It causes the client to get undefined as firstKey so providing firstKey has no effect at all and then when running lua scripts you cannot provide hash keys to begin with which might cause unexpected errors and unresolvable failures.
I solved it in a dirty way just as a POC, I modified in EVALSHA module which is located in:
// exports.FIRST_KEY_INDEX = generic_transformers_1.evalFirstKeyIndex;// custom function for EVALSHA input...functionevalFirstKeyIndex(...args){if(args&&args.length>0){constoptions=args[1]if(options.keys&&options.keys.length>0){returnoptions.keys[0]}}returnundefined}exports.FIRST_KEY_INDEX=evalFirstKeyIndex;
Description
EVAL && EVALSHA commands infers wrong node by key hash slot on cluster mode.
Usage in abstract:
As of my understanding each command uses the
FIRST_KEY_INDEX
function that's defined in it's module and then based on that the node is inferred based on the hash slot of first key.On file:
There is generic function that is used to extract firstKey before inferring client pre command or after MOVE error.
So, in addition to that, the EVAL && EVALSHA modules has this declaration for the function to use.
While the function is:
So, in essence what happens is that the
evalFirstKeyIndex
gets options as a list and it does not having a keys object in it. maybe the second item in the list will have. as in the scope of theextractFirstKey
fn the originalArgs is actualy the input of original evalSha call.It causes the client to get undefined as firstKey so providing firstKey has no effect at all and then when running lua scripts you cannot provide hash keys to begin with which might cause unexpected errors and unresolvable failures.
I solved it in a dirty way just as a POC, I modified in EVALSHA module which is located in:
This change:
And it seem to solve the issue
Node.js Version
v20.11.0
Redis Server Version
7.2.2
Node Redis Version
[email protected]
Platform
Linux
Logs
No response
The text was updated successfully, but these errors were encountered: