Modified to use 'SELECT...FOR UPDATE' for MySQL when locking a job