redis/tests/modules
Yuan Wang 951ec79654
CI / build-macos-latest (push) Waiting to run Details
CI / build-32bit (push) Failing after 31s Details
CI / build-libc-malloc (push) Failing after 31s Details
CI / build-debian-old (push) Failing after 1m32s Details
CI / build-old-chain-jemalloc (push) Failing after 31s Details
Codecov / code-coverage (push) Failing after 31s Details
CI / test-ubuntu-latest (push) Failing after 3m21s Details
Spellcheck / Spellcheck (push) Failing after 31s Details
CI / test-sanitizer-address (push) Failing after 6m36s Details
CI / build-centos-jemalloc (push) Failing after 6m36s Details
External Server Tests / test-external-standalone (push) Failing after 2m10s Details
Coverity Scan / coverity (push) Has been skipped Details
External Server Tests / test-external-nodebug (push) Failing after 2m12s Details
External Server Tests / test-external-cluster (push) Failing after 2m16s Details
Cluster compatibility check (#13846)
### Background
The program runs normally in standalone mode, but migrating to cluster
mode may cause errors, this is because some cross slot commands can not
run in cluster mode. We should provide an approach to detect this issue
when running in standalone mode, and need to expose a metric which
indicates the usage of no incompatible commands.

### Solution
To avoid perf impact, we introduce a new config
`cluster-compatibility-sample-ratio` which define the sampling ratio
(0-100) for checking command compatibility in cluster mode. When a
command is executed, it is sampled at the specified ratio to determine
if it complies with Redis cluster constraints, such as cross-slot
restrictions.

A new metric is exposed: `cluster_incompatible_ops` in `info stats`
output.

The following operations will be considered incompatible operations.

- cross-slot command
   If a command has multiple cross slot keys, it is incompatible
- `swap, copy, move, select` command
These commands involve multi databases in some cases, we don't allow
multiple DB in cluster mode, so there are not compatible
- Module command with `no-cluster` flag
If a module command has `no-cluster` flag, we will encounter an error
when loading module, leading to fail to load module if cluster is
enabled, so this is incompatible.
- Script/function with `no-cluster` flag
Similar with module command, if we declare `no-cluster` in shebang of
script/function, we also can not run it in cluster mode
- `sort` command by/get pattern
When `sort` command has `by/get` pattern option, we must ask that the
pattern slot is equal with the slot of keys, otherwise it is
incompatible in cluster mode.

- The script/function command accesses the keys and declared keys have
different slots
For the script/function command, we not only check the slot of declared
keys, but only check the slot the accessing keys, if they are different,
we think it is incompatible.

**Besides**, commands like `keys, scan, flushall, script/function
flush`, that in standalone mode iterate over all data to perform the
operation, are only valid for the server that executes the command in
cluster mode and are not broadcasted. However, this does not lead to
errors, so we do not consider them as incompatible commands.

### Performance impact test
**cross slot test**
Below are the test commands and results. When using MSET with 8 keys,
performance drops by approximately 3%.

**single key test**
It may be due to the overhead of the sampling function, and single-key
commands could cause a 1-2% performance drop.
2025-03-20 10:35:53 +08:00
..
Makefile Add internal connection and command mechanism (#13740) 2025-02-05 11:48:08 +02:00
aclcheck.c Modules API: Add RedisModule_ACLCheckKeyPrefixPermissions (#13666) 2024-11-28 18:33:58 +02:00
auth.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
basics.c Add flag for ability of a module context to execute debug commands (#13774) 2025-02-03 09:52:41 +02:00
blockedclient.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
blockonbackground.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
blockonkeys.c Modules: Unblock from within a timer coverage (#12337) 2023-06-22 23:15:16 +03:00
cmdintrospection.c Overhauls command summaries and man pages. (#11942) 2023-03-29 20:48:59 +03:00
commandfilter.c Un-register notification and server event when RedisModule_OnLoad fails (#12809) 2023-11-27 17:26:33 +02:00
crash.c Print command tokens on a crash when hide-user-data-from-log is enabled (#13639) 2024-11-11 09:34:18 +03:00
datatype.c Fix module loadex command crash due to invalid config (#13653) 2024-11-21 14:14:14 +08:00
datatype2.c Use const char pointer in redismodule.h as far as possible (#10064) 2022-01-18 15:55:20 +02:00
defragtest.c Make RM_DefragRedisModuleDict API support incremental defragmentation for dict leaf (#13840) 2025-03-04 17:19:41 +08:00
eventloop.c delete obsolete REDISMODULE_EXPERIMENTAL_API define in module demos (#10527) 2022-04-05 08:21:41 +03:00
fork.c Fix race in module fork kill test (#10717) 2022-05-12 20:10:38 +03:00
getchannels.c Implemented module getchannels api and renamed channel keyspec (#10299) 2022-02-22 11:00:03 +02:00
getkeys.c Handle key-spec flags with modules (#10237) 2022-02-08 10:01:35 +02:00
hash.c Modules API: new HashFieldMinExpire(). Add flag REDISMODULE_HASH_EXPIRE_TIME to HashGet(). (#13676) 2024-12-05 11:14:52 +02:00
hooks.c Change license from BSD-3 to dual RSALv2+SSPLv1 (#13157) 2024-03-20 22:38:24 +00:00
infotest.c Update supported version list. (#12488) 2023-08-16 08:36:40 +03:00
internalsecret.c Add internal connection and command mechanism (#13740) 2025-02-05 11:48:08 +02:00
keyspace_events.c Change license from BSD-3 to dual RSALv2+SSPLv1 (#13157) 2024-03-20 22:38:24 +00:00
keyspecs.c RM_CreateCommand should not set CMD_KEY_VARIABLE_FLAGS automatically (#11320) 2022-09-28 14:15:07 +03:00
list.c Fix crash due to to reuse iterator entry after list deletion in module (#11383) 2022-10-22 20:36:50 +03:00
mallocsize.c Add RM_MallocSizeString, RM_MallocSizeDict (#10542) 2022-04-17 08:31:57 +03:00
misc.c Cluster compatibility check (#13846) 2025-03-20 10:35:53 +08:00
moduleauthtwo.c Custom authentication for Modules (#11659) 2023-03-15 15:18:42 -07:00
moduleconfigs.c Update tests/modules/moduleconfigs.c 2025-02-06 13:16:33 +02:00
moduleconfigstwo.c Module Configurations (#10285) 2022-03-30 15:47:06 +03:00
postnotifications.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
propagate.c Don't keep global replication buffer reference for replicas marked CLIENT_CLOSE_ASAP (#13363) 2024-06-26 08:26:23 +08:00
publish.c Fix broken protocol when PUBLISH emits local push inside MULTI (#12326) 2023-06-20 20:41:41 +03:00
rdbloadsave.c Add RM_RdbLoad and RM_RdbSave module API functions (#11852) 2023-04-09 12:07:32 +03:00
reply.c Add RM_ReplyWithErrorFormat that can support format (#11923) 2023-04-12 10:11:29 +03:00
scan.c Replace deprecated REDISMODULE_POSTPONED_ARRAY_LEN in module tests and examples (#9677) 2021-10-25 12:00:43 +03:00
stream.c Sort out the mess around writable replicas and lookupKeyRead/Write (#9572) 2021-11-28 11:26:28 +02:00
subcommands.c Block some specific characters in module command names (#11434) 2022-11-03 13:19:49 +02:00
test_lazyfree.c Sort out the mess around writable replicas and lookupKeyRead/Write (#9572) 2021-11-28 11:26:28 +02:00
testrdb.c Avoid saving module aux on RDB if no aux data was saved by the module. (#11374) 2022-10-18 19:45:46 +03:00
timer.c Modules: Mark all APIs non-experimental (#9983) 2021-12-30 12:17:22 +02:00
usercall.c Fix daylight race condition and some thread leaks (#13191) 2024-04-04 13:49:51 +03:00
zset.c Delete empty key if fails after moduleCreateEmptyKey() in module (#12129) 2023-05-07 10:13:19 +03:00