@@ -78,7 +78,7 @@ static int _ParseDAGLoadArgs(RedisModuleCtx *ctx, RedisModuleString **argv, int
78
78
79
79
/**
80
80
* DAGRUN Building Block to parse [PERSIST <nkeys> key1 key2... ]
81
- *
81
+ * @param ctx Context in which Redis modules operate
82
82
* @param argv Redis command arguments, as an array of strings
83
83
* @param argc Redis command number of arguments
84
84
* @param persistTensorsNames local hash table containing DAG's
@@ -87,8 +87,8 @@ static int _ParseDAGLoadArgs(RedisModuleCtx *ctx, RedisModuleString **argv, int
87
87
* argument after the chaining operator is not considered
88
88
* @return processed number of arguments on success, or -1 if the parsing failed
89
89
*/
90
- static int _ParseDAGPersistArgs (RedisModuleString * * argv , int argc , AI_dict * persistTensorsNames ,
91
- RAI_Error * err ) {
90
+ static int _ParseDAGPersistArgs (RedisModuleCtx * ctx , RedisModuleString * * argv , int argc ,
91
+ AI_dict * persistTensorsNames , RAI_Error * err ) {
92
92
if (argc < 3 ) {
93
93
RAI_SetError (err , RAI_EDAGBUILDER ,
94
94
"ERR missing arguments after PERSIST keyword in DAG command" );
@@ -106,11 +106,16 @@ static int _ParseDAGPersistArgs(RedisModuleString **argv, int argc, AI_dict *per
106
106
// Go over the given args and save the tensor key names to persist.
107
107
int number_keys_to_persist = 0 ;
108
108
for (size_t argpos = 2 ; (argpos < argc ) && (number_keys_to_persist < n_keys ); argpos ++ ) {
109
- const char * arg_string = RedisModule_StringPtrLen (argv [argpos ], NULL );
110
109
if (AI_dictFind (persistTensorsNames , (void * )argv [argpos ]) != NULL ) {
111
110
RAI_SetError (err , RAI_EDAGBUILDER , "ERR PERSIST keys must be unique" );
112
111
return -1 ;
113
112
}
113
+ if (!VerifyKeyInThisShard (ctx , argv [argpos ])) { // Relevant for enterprise cluster.
114
+ RAI_SetError (
115
+ err , RAI_EDAGBUILDER ,
116
+ "ERR Found keys to persist in DAG command that don't hash to the local shard" );
117
+ return -1 ;
118
+ }
114
119
AI_dictAdd (persistTensorsNames , (void * )argv [argpos ], NULL );
115
120
number_keys_to_persist ++ ;
116
121
}
@@ -267,7 +272,7 @@ int DAGInitialParsing(RedisAI_RunInfo *rinfo, RedisModuleCtx *ctx, RedisModuleSt
267
272
/* Store the keys to persist in persistTensors dict, these keys will
268
273
* be mapped later to the indices in the dagSharedTensors array in which the
269
274
* tensors to persist will be found by the end of the DAG run. */
270
- const int parse_result = _ParseDAGPersistArgs (& argv [arg_pos ], argc - arg_pos ,
275
+ const int parse_result = _ParseDAGPersistArgs (ctx , & argv [arg_pos ], argc - arg_pos ,
271
276
rinfo -> persistTensors , rinfo -> err );
272
277
if (parse_result <= 0 )
273
278
return REDISMODULE_ERR ;
0 commit comments