Under load, the following job-queue design does not work reliably, why?
In similar situation I use:

DECLARE CONTINUE HANDLER FOR NOT FOUND BEGIN END;

REPEAT

    UPDATE job_queue
    SET status = "WORKING", job_id = &lt;arg_unique_job_id&gt;
    WHERE status = "NEW"
    LIMIT 1;

    SELECT *
    FROM job_queue
    WHERE job_id = &lt;arg_unique_job_id&gt;;

UNTIL row_count() &lt; 1 END REPEAT;


It's never gone wrong before.

PS. This construction was used in the case when a record free for reservation exists with guarantee. If not use some local variable (some @loopcount) for to limit the max amount of cycles to avoid infinite loop.