Skip to content

Commit 9d07aa5

Browse files
committed
Return error if we run from MULTI or LUA
1 parent 2d0f084 commit 9d07aa5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/redisai.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ int RedisAI_ModelRun_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
569569
if (RedisModule_IsKeysPositionRequest(ctx)) {
570570
return RedisAI_ModelRun_IsKeysPositionRequest_ReportKeys(ctx, argv, argc);
571571
}
572+
int flags = RedisModule_GetContextFlags(ctx);
573+
bool blocking_not_allowed = (flags & (REDISMODULE_CTX_FLAGS_MULTI | REDISMODULE_CTX_FLAGS_LUA));
574+
if (blocking_not_allowed)
575+
return RedisModule_ReplyWithError(
576+
ctx, "ERR Cannot run RedisAI command within a transaction or a LUA script");
572577

573578
// Build a ModelRunCtx from command.
574579
RAI_Error error = {0};

0 commit comments

Comments
 (0)