summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorguybe7 <guy.benoish@redislabs.com>2023-02-14 08:33:21 +0100
committerGitHub <noreply@github.com>2023-02-14 09:33:21 +0200
commitfd82bccd0ee915909494c6b552dbcc02b9427993 (patch)
tree1bf6f6397fa04f55102e817b04563bcc27f3ed50 /src/commands
parent7dae142a2ebf909a63df13e5813c073c79be521f (diff)
downloadredis-fd82bccd0ee915909494c6b552dbcc02b9427993.tar.gz
SCAN/RANDOMKEY and lazy-expire (#11788)
Starting from Redis 7.0 (#9890) we started wrapping everything a command propagates with MULTI/EXEC. The problem is that both SCAN and RANDOMKEY can lazy-expire arbitrary keys (similar behavior to active-expire), and put DELs in a transaction. Fix: When these commands are called without a parent exec-unit (e.g. not in EVAL or MULTI) we avoid wrapping their DELs in a transaction (for the same reasons active-expire and eviction avoids a transaction) This PR adds a per-command flag that indicates that the command may touch arbitrary keys (not the ones in the arguments), and uses that flag to avoid the MULTI-EXEC. For now, this flag is internal, since we're considering other solutions for the future. Note for cluster mode: if SCAN/RANDOMKEY is inside EVAL/MULTI it can still cause the same situation (as it always did), but it won't cause a CROSSSLOT because replicas and AOF do not perform slot checks. The problem with the above is mainly for 3rd party ecosystem tools that propagate commands from master to master, or feed an AOF file with redis-cli into a master. This PR aims to fix the regression in redis 7.0, and we opened #11792 to try to handle the bigger problem with lazy expire better for another release.
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/randomkey.json3
-rw-r--r--src/commands/scan.json3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/commands/randomkey.json b/src/commands/randomkey.json
index 93473968c..ceaa3c886 100644
--- a/src/commands/randomkey.json
+++ b/src/commands/randomkey.json
@@ -7,7 +7,8 @@
"arity": 1,
"function": "randomkeyCommand",
"command_flags": [
- "READONLY"
+ "READONLY",
+ "TOUCHES_ARBITRARY_KEYS"
],
"acl_categories": [
"KEYSPACE"
diff --git a/src/commands/scan.json b/src/commands/scan.json
index a689bacca..e0856d0f0 100644
--- a/src/commands/scan.json
+++ b/src/commands/scan.json
@@ -13,7 +13,8 @@
]
],
"command_flags": [
- "READONLY"
+ "READONLY",
+ "TOUCHES_ARBITRARY_KEYS"
],
"acl_categories": [
"KEYSPACE"