Limitations on Commands Supported by Cluster Instances - ApsaraDB for Redis (2023)

This topic describes the limitations of commands supported by cluster instances. Cluster instances and standard instances use different architectures and follow different rules for running Redis commands.

Supported Commands

  • ApsaraDB for Redis Community Edition Cluster Instances - For more information, seeCommands supported by ApsaraDB for Redis Community Edition.
  • ApsaraDB for Redis Enhanced Edition (Tair) Cluster Instances: ApsaraDB for Redis Enhanced Edition (Tair) offers a variety of instance series for different scenarios. Different sets of instances follow different rules for running Redis commands. For more information, seeLimitations of commands supported by ApsaraDB for Redis Enhanced Edition (Tair)..

UseApsaraDB for Redis cluster instances support both direct connection mode and proxy mode. For more information, seeEnable direct connection modeyProxy server functions🇧🇷 If you want to run MULTI or EXEC command from JedisCluster client, you must use proxy mode.

unsupported commands

  • SWAPDB
  • CLIENT ID
  • SORT, which is used in conjunction with theVONyRECEIVEoptions

limited commands

UseTo run the following commands on cluster instances, use hash tags to ensure that all keys involved in the commands are distributed in a hash slot. For more information about hashtags, seeRedis Cluster Specification.

(Video) Clustering in Redis
command group domain
HyperLogLog PFMERGE e PFCOUNT
key RENAME, RENAMEX e ORDER
listening RPOPLPUSH, BRPOP, BLPOP e BRPOPLPUSH
scripts EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL e SCRIPT LOAD
Satan MSETNX
transaction DISCARD, EXECUTE, MULTI, UNWATCH and WATCH

Restrictions on the SELECT command

connection mode Description
Modo Proxy Proxy mode supports the SELECT command. Certain Redis clients, such as stackExchange.redis, cannot distinguish the SELECT command. To fix this issue, you can use thecluster_compat_enableparameters to0for these customers to disable Redis cluster syntax support. You can restart these clients and run the SELECT command again. For more information, seeChanging parameters of an instance🇧🇷 You can also use other clients that support this command, eg. B. the Jedi client. For more information about the Jedis client, seeClient of Jedi.
direct connect mode Direct connect mode does not support the SELECT command due to limitations of major Redis clients such as the Jedis client.

Restrictions on Lua scripts on cluster instances

embargoThe cluster architecture imposes limits on Lua scripts. If you change the architecture of an instance to the cluster architecture through a configuration change, the Lua scripts might be lost because the script content does not meet the requirements. You should back up your Lua scripts in advance. For more information about configuration changes, seeChange an instance's settings.

Redis clusters impose restrictions on using Lua scripts. The following additional limitations apply to ApsaraDB for Redis cluster instances:

UseIf an error message is returned indicating that the EVAL command cannot be executed, such asERR command evaluation is not supported by normal users, upgrade the minor version of the ApsaraDB for Redis instance to the latest version. For more information about the procedure, seeUpdate minor version.

(Video) Redis: How to setup a cluster - for beginners
  • All keys used by a script must be assigned the same hash slot. Otherwise, the following error message is returned:
    -ERR eval/evalsha command keys must be in the same slot\r\n

    UseYou can run the CLUSTER KEYSLOT command to get the hash slot of a key.

  • A Lua script must not be stored on other nodes when executing the SCRIPT LOAD command on a node.
  • The following Pub/Sub commands are not supported:SUBSCRIBE TO,PUBSUB,POST,Sign up for the word game,SUBSCRIBE TO, youDISCONNECT.
  • The UNPACK function is not supported.

If all operations can be performed in the same hash slot and you want to break the limitations that the cluster architecture imposes on your Lua script, you can use thescript_check_enableparameters to0in the ApsaraDB for Redis console. That way, the system doesn't check your Lua script in the backend. In this case, you must provide at least one key in the KEYS array to allow proxy nodes to forward commands in the Lua script. If it cannot guarantee that all operations are performed on the same hash clot, an error is returned. For more information, seeChanging parameters of an instance.

Additional Restrictions for Proxy Mode

(Video) What is Redis and What Does It Do?

  • Lua scripts use theredis.call or redis.pcallFunction to run Redis commands. For Redis commands, all keys must be specified using the KEYS array, which cannot be replaced by Lua variables. If you do not use the KEYS array to specify the keys, the following error message is returned:
    -ERR bad lua script for redis cluster, all keys used by script must be passed with array of KEYS\r\n

    Examples of valid and invalid usage:

    # The following two commands must be executed previously. SET foo foo_valueSET {foo}bar bar_value# Examples of valid usageEVAL "return redis.call('mget', KEYS[1], KEYS[2])" 2 foo {foo} bar# Examples of invalid usageEVAL "return redis. call ('mget', KEYS[1], '{foo}bar')" 1 fooEVAL "return redis.call('mget', KEYS[1], ARGV[1] )" 1 foo {foo} bar
  • Braces must be included in every command you want to run. Otherwise, the following error message is returned:
    -ERR for Redis cluster, number of eval/evalsha keys cannot be negative or zero\r\n

    Examples of valid and invalid usage:

    # Examples of valid useEVAL "return redis.call('get', KEYS[1])" 1 foo# Examples of invalid useEVAL "return redis.call('get', 'foo')" 0
  • You cannot issue EVAL, EVALSHA, or SCRIPT commands in MULTI or EXEC transactions.
  • Commands such as KEYS or SCAN that affect several Redis nodes are not allowed.

    To ensure that the execution of Lua scripts is atomic, proxy nodes send Lua scripts to a designated Redis node for execution using the KEYS command and receive the result. This leads to inconsistency in the command output for this node and all other nodes.

    (Video) Redis Crash Course

Use

If you want to use features that are not available for proxy mode, you can enable directional connection mode for your ApsaraDB for Redis cluster instance. However, migrations or configuration changes fail for cluster instances when Lua scripts that do not meet proxy mode requirements are run in direct connect mode. This is because cluster instances rely on proxy nodes to migrate data during migrations and configuration changes.

To prevent subsequent migrations and configuration changes based on Lua scripts from failing, we recommend that you follow the restrictions on using Lua scripts in proxy mode when using Lua scripts. in direct connection mode.

(Video) Can Redis be used as a Primary database?

other borders

  • You can run the CLIENT LIST command to obtain information about connections to the specified proxy node. The following list describes the fields in the command output:
    • The following fields have the same meaning as fields in open source Redis:I would like to,years old,Neutral,direction,f.d.,Name,database,multi,but, youcmd.
    • the values ​​ofsubypsubthe fields are the same. Values ​​are 1 or 0.
    • To besmell,qbuf free,obl, youWe willFields are reserved. You can ignore these fields.
  • You can run the CLIENT KILL command inkill client ip:portocliente kill addr ip:portFormat.
  • When you run commands on a clustered instance inModo Proxy, a transaction can be split into multiple subtransactions to ensure compatibility with the main replica architecture. In this case, transaction atomicity cannot be guaranteed. When you run commands on a clustered instance indirect connect mode, the keys involved in a transaction must be in the same hash slot. This requirement is the same as the open source Redis cluster.

    UseWhen you run the WATCH command in proxy mode or a transaction contains commands that process multiple keys, such as the B.MSET command, the transaction is not split. If all keys involved in the transaction are in the same hash slot, the atomicity of the transaction can be guaranteed.

    • Commands that handle multiple keys include DEL, SORT, MGET, MSET, BITOP, EXISTS, MSETNX, RENAME, RENAMENX, BLPOP, BRPOP, RPOPLPUSH, BRPOPLPUSH, SMOVE, SUNION, SINTER, SDIFF, SUNIONSTORE, SINTERSTORE, SDIFFSTORE, ZUNIONSTORE, ZINTERSTORE , PFMERGE and PFCOUNT.
    • Commands that are not supported in transactions include WATCH, UNWATCH, RANDOMKEY, KEYS, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, SCRIPT, EVAL, EVALSHA, SCAN, ISCAN, DBSIZE, ADMINAUTH, AUTH, PING, ECHO, FLUSHDB, FLUSHALL, MONITOR, IMONITOR, RIMONITOR, INFO, IINFO, RIINFO, CONFIG, SLOWLOG, TIME and CLIENT.

Videos

1. ApsaraDB | Dive Deep Into ApsaraDB for Redis On Alibaba Cloud
(Alibaba Cloud)
2. Redis Course - In-Memory Database Tutorial
(freeCodeCamp.org)
3. Querying, Indexing, and Full-text Search in Redis
(Redis)
4. Redis Crash Course Tutorial
(Traversy Media)
5. Redis : The Basics for beginners
(That DevOps Guy)
6. Turbocharge your Amazon RDS database applications with Amazon ElastiCache for Redis
(AWS Online Tech Talks)
Top Articles
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated: 04/17/2023

Views: 6405

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.