Don't use threaded VADD in replicas, lua, multi.

This commit is contained in:
antirez 2025-02-03 11:28:48 +01:00
parent 285134e43d
commit 337fc3d6fd

21
vset.c
View file

@ -297,13 +297,6 @@ int VADD_CASReply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
RedisModule_DictSet(vset->dict,val,newnode);
val = NULL; // Don't free it later.
/* FIXME: probably it's better to drop the CAS argument when
* replicating. Other VADDs with CAS against the same item may arrive
* and can be executed out of order. Also DEL commands may arrive
* while the VADD is in progress.
*
* The problem of dropping CAS however is that the replica may no
* longer be able to keep with the insertion load. */
RedisModule_ReplicateVerbatim(ctx);
}
@ -358,6 +351,20 @@ int VADD_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
}
}
/* Drop CAS if this is a replica and we are getting the command from the
* replication link: we want to add/delete items in the same order as
* the master, while with CAS the timing would be different.
*
* Also for Lua scripts and MULTI/EXEC, we want to run the command
* on the main thread. */
if (RedisModule_GetContextFlags(ctx) &
(REDISMODULE_CTX_FLAGS_REPLICATED|
REDISMODULE_CTX_FLAGS_LUA|
REDISMODULE_CTX_FLAGS_MULTI))
{
cas = 0;
}
/* Open/create key */
RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);