mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
bb2b6e2927
Regarding how to obtain the hash slot of a key, there is an optimization in `getKeySlot()`, it is used to avoid redundant hash calculations for keys: when the current client is in the process of executing a command, it can directly use the slot of the current client because the slot to access has already been calculated in advance in `processCommand()`. However, scripts are a special case where, in default mode or with `allow-cross-slot-keys` enabled, they are allowed to access keys beyond the pre-declared range. This means that the keys they operate on may not belong to the slot of the pre-declared keys. Currently, when the commands in a script are executed, the slot of the original client (i.e., the current client) is not correctly updated, leading to subsequent access to the wrong slot. This PR fixes the above issue. When checking the cluster constraints in a script, the slot to be accessed by the current command is set for the original client (i.e., the current client). This ensures that `getKeySlot()` gets the correct slot cache. Additionally, the following modifications are made: 1. The 'sort' and 'sort_ro' commands use `getKeySlot()` instead of `c->slot` because the client could be an engine client in a script and can lead to potential bug. 2. `getKeySlot()` is also used in pubsub to obtain the slot for the channel, standardizing the way slots are retrieved. |
||
---|---|---|
.. | ||
announced-endpoints.tcl | ||
cli.tcl | ||
cluster-response-tls.tcl | ||
failure-marking.tcl | ||
hostnames.tcl | ||
human-announced-nodename.tcl | ||
links.tcl | ||
misc.tcl | ||
multi-slot-operations.tcl | ||
scripting.tcl | ||
slot-ownership.tcl |