Is the rule must be obeyed?

110 views
Skip to first unread message

feiyu...@etix.com

unread,
Mar 23, 2022, 8:42:40 AM3/23/22
to Redis DB

I say the following statement in https://redis.io/commands/eval. But in our production, most of the keys used by the scripts generated programmatically and the scripts are dealing quite complex logic, and we don't find an issue regard to this rule in half a decade. Can anyone explain why this rule is important? thanks!

Important: to ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments. The script should only access keys whose names are given as input arguments. Scripts should never access keys with programmatically-generated names or based on the contents of data structures stored in the database.

David Maier (Redis)

unread,
Mar 23, 2022, 4:04:20 PM3/23/22
to redi...@googlegroups.com
Hi,

this rule enforces awareness about which keys are passed over to the script. I have seen the following issues with auto-generated keys in the past:
  • Cross-slot execution errors because the key generation didn't anticipate that Redis LUA scripts can only run on keys that are mapped to the same hash slot
  • Very large functions with a lot of different execution paths that didn't take future scalability needs into account.
  • Related is that auto-generated keys might also lead to imbalances across the slots/nodes.
So it might be that you never face an issue with it as long as you are running on a single instance of Redis. As soon as you need to scale (cluster), huge scripts with auto-generated keys will make your life much harder to scale horizontally. The solution was usually to break the scripts up into smaller functional units by thinking more carefully about which input keys should be passed over. All keys that you pass over are expected to be mapped to the same slot (e.g., by using hash-tags).

Regards,
David

On Wed, Mar 23, 2022 at 1:42 PM feiyu...@etix.com <feiyu...@etix.com> wrote:

I say the following statement in https://redis.io/commands/eval. But in our production, most of the keys used by the scripts generated programmatically and the scripts are dealing quite complex logic, and we don't find an issue regard to this rule in half a decade. Can anyone explain why this rule is important? thanks!

Important: to ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments. The script should only access keys whose names are given as input arguments. Scripts should never access keys with programmatically-generated names or based on the contents of data structures stored in the database.

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/6b3dd1ee-f5d1-41e8-b46f-b2bea01c67ffn%40googlegroups.com.


Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

feiyu...@etix.com

unread,
Mar 25, 2022, 2:14:06 AM3/25/22
to Redis DB
Thank you David!
I have one more question, you said "So it might be that you never face an issue with it as long as you are running on a single instance of Redis." yes, indeed, we use only one master and two slaves, but the rule said, it also applies to standalone deployment. I wonder what the problem could be when we violate the rule in standalone deployment if we don't need to worry about scaling it up in future.

Itamar Haber

unread,
Mar 25, 2022, 6:57:10 AM3/25/22
to Redis DB
Hey Feiyu - there shouldn't be any consequences if you violate the "rule" in a single-instance deployment.

Cheers,
Itamar

feiyu...@etix.com

unread,
Mar 27, 2022, 10:47:24 PM3/27/22
to Redis DB
Thank you Itamar! Do you know why the language include "standalone"?
> Important: to ensure the correct execution of scripts, both in standalone and clustered deployments, all names of keys that a script accesses must be explicitly provided as input key arguments. The script should only access keys whose names are given as input arguments. Scripts should never access keys with programmatically-generated names or based on the contents of data structures stored in the database.

Reply all
Reply to author
Forward
0 new messages