@@ -154,7 +154,6 @@ static void _BGThread_ExecutionFinish(RunQueueInfo *run_queue_info, RedisAI_RunI
154154}
155155
156156static void _BGThread_Execute (RunQueueInfo * run_queue_info , RedisAI_RunInfo * * batch_rinfo ) {
157- pthread_mutex_unlock (& run_queue_info -> run_queue_mutex );
158157 uint n_rinfo = array_len (batch_rinfo );
159158 if (n_rinfo != 0 ) {
160159 bool batched_run = n_rinfo > 1 ;
@@ -166,9 +165,6 @@ static void _BGThread_Execute(RunQueueInfo *run_queue_info, RedisAI_RunInfo **ba
166165 RedisAI_DagRunSessionStep (batch_rinfo [0 ], run_queue_info -> devicestr );
167166 }
168167 }
169- // Lock the queue again: we're done operating on evicted items only.
170- pthread_mutex_lock (& run_queue_info -> run_queue_mutex );
171- _BGThread_ExecutionFinish (run_queue_info , batch_rinfo );
172168}
173169
174170static RedisAI_RunInfo * * _BGThread_BatchOperations (RunQueueInfo * run_queue_info , RedisAI_RunInfo * rinfo ,RedisAI_RunInfo * * batch_rinfo ) {
@@ -317,8 +313,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
317313 // safely unlock the queue mutex, to allow other threads to operate
318314 // on the same queue. The evicted items at this point are only visible
319315 // to this worker.
320-
316+ pthread_mutex_unlock ( & run_queue_info -> run_queue_mutex );
321317 _BGThread_Execute (run_queue_info , batch_rinfo );
318+ // Lock the queue again: we're done operating on evicted items only.
319+ pthread_mutex_lock (& run_queue_info -> run_queue_mutex );
320+ _BGThread_ExecutionFinish (run_queue_info , batch_rinfo );
322321
323322 }
324323 }
0 commit comments