diff options
author | Binbin <binloveplay1314@qq.com> | 2022-06-12 13:22:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-12 08:22:18 +0300 |
commit | 92fb4f4f61bc430aec30105e24d1dc148a4d6466 (patch) | |
tree | aa56a2db3c730f31f73254a9fb24e9d9a3aa44e8 /src/server.h | |
parent | 62ac1ab007b9ba25588671fdefd0025028030504 (diff) | |
download | redis-92fb4f4f61bc430aec30105e24d1dc148a4d6466.tar.gz |
Fixed SET and BITFIELD commands being wrongly marked movablekeys (#10837)
The SET and BITFIELD command were added `get_keys_function` in #10148, causing
them to be wrongly marked movablekeys in `populateCommandMovableKeys`.
This was an unintended side effect introduced in #10148 (7.0 RC1)
which could cause some clients an extra round trip for these commands in cluster mode.
Since we define movablekeys as a way to determine if the legacy range [first, last, step]
doesn't find all keys, then we need a completely different approach.
The right approach should be to check if the legacy range covers all key-specs,
and if none of the key-specs have the INCOMPLETE flag.
This way, we don't need to look at getkeys_proc of VARIABLE_FLAG at all.
Probably with the exception of modules, who may still not be using key-specs.
In this PR, we removed `populateCommandMovableKeys` and put its logic in
`populateCommandLegacyRangeSpec`.
In order to properly serve both old and new modules, we must probably keep relying
CMD_MODULE_GETKEYS, but do that only for modules that don't declare key-specs.
For ones that do, we need to take the same approach we take with native redis commands.
This approach was proposed by Oran. Fixes #10833
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/server.h')
-rw-r--r-- | src/server.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/server.h b/src/server.h index 6dfa8a067..abaa5f046 100644 --- a/src/server.h +++ b/src/server.h @@ -215,7 +215,8 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; #define CMD_MODULE_NO_CLUSTER (1ULL<<22) /* Deny on Redis Cluster. */ #define CMD_NO_ASYNC_LOADING (1ULL<<23) #define CMD_NO_MULTI (1ULL<<24) -#define CMD_MOVABLE_KEYS (1ULL<<25) /* populated by populateCommandMovableKeys */ +#define CMD_MOVABLE_KEYS (1ULL<<25) /* The legacy range spec doesn't cover all keys. + * Populated by populateCommandLegacyRangeSpec. */ #define CMD_ALLOW_BUSY ((1ULL<<26)) #define CMD_MODULE_GETCHANNELS (1ULL<<27) /* Use the modules getchannels interface. */ @@ -3550,7 +3551,6 @@ void mixDigest(unsigned char *digest, const void *ptr, size_t len); void xorDigest(unsigned char *digest, const void *ptr, size_t len); sds catSubCommandFullname(const char *parent_name, const char *sub_name); void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subcommand, const char *declared_name); -void populateCommandMovableKeys(struct redisCommand *cmd); void debugDelay(int usec); void killIOThreads(void); void killThreads(void); |