Make sure we do not propagate nested MULTI/EXEC#8097
Make sure we do not propagate nested MULTI/EXEC#8097oranagra merged 3 commits intoredis:unstablefrom
Conversation
|
for the record: a cleaner solution would be if the RM_Call client would inherit the CLIENT_MULTI flag from the "caller" (so we won't need |
|
@oranagra i'm using a server var inside |
|
@guybe7 i suppose what's stopping you from taking the "cleaner solution" is that you didn't want to pass an extra argument to all the calls to |
src/module.c
Outdated
| * RedisModuleCommandDispatcher() function. */ | ||
| void moduleReplicateMultiIfNeeded(RedisModuleCtx *ctx) { | ||
| /* Skip this if server has already emitted MULTI */ | ||
| if (server.propagate_in_transaction) return; |
There was a problem hiding this comment.
maybe CLIENT_MULTI|CLIENT_LUA is redundant, add assertio
One way this was happening is when a module issued an RM_Call which would inject MULTI. If the module command that does that was itself issued by something else that already did added MULTI (e.g. another module, or a Lua script), it would have caused nested MULTI. In fact the MULTI state in the client or the MULTI_EMITTED flag in the context isn't the right indication that we need to propagate MULTI or not, because on a nested calls (possibly a module action called by a keyspace event of another module action), these flags aren't retained / reflected. instead there's now a global propagate_in_transaction flag for that. in addition to that, we now have a global in_eval and in_exec flags, to serve the flags of RM_GetContextFlags, since their dependence on the current client is wrong for the same reasons mentioned above.
Fix #8049