Fix another race issue in search_jobs_not_done().

See comment https://github.com/giomasce/cms/commit/f0624f92ad4741eac643f99b3f1de9e2aeee334a#commitcomment-6760124
for details.