From c021b1c79242b6e42ddde52bd5702e7cf2370edd Mon Sep 17 00:00:00 2001 From: Mike Davis Date: Wed, 28 Apr 2021 12:16:11 -0400 Subject: [PATCH] rex.job: fix a race condition in transitioning a job from "new" to "queued" --- src/rex.job/src/rex/job/workers/job_queuer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rex.job/src/rex/job/workers/job_queuer.py b/src/rex.job/src/rex/job/workers/job_queuer.py index 966d63977..5a1ee6a79 100644 --- a/src/rex.job/src/rex/job/workers/job_queuer.py +++ b/src/rex.job/src/rex/job/workers/job_queuer.py @@ -33,8 +33,10 @@ )) ''' +# Note that we only change the status to queued if it is still new. +# This is to avoid a race condition where the job may already be completed/failed. HTSQL_UPDATE_NEW = ''' -/job[$job]{ +/job[$job].filter(status='new'){ id(), 'queued' :as status, }