Update the job_status to in-progress sooner.

We had a situation where the delivery-worker app instance was terminated before the job was marked as `in-progress`, presumably because the query to check the daily limits was taking too long to complete.
If the job was in progress the `check_job_status` task would have restarted the job.
Updating the status to in-progress sooner will help.
This commit is contained in:
Rebecca Law
2021-06-15 07:58:17 +01:00
parent ec646c3071
commit 8af10eb1f0

View File

@@ -71,6 +71,10 @@ def process_job(job_id, sender_id=None):
service = job.service service = job.service
job.job_status = JOB_STATUS_IN_PROGRESS
job.processing_started = start
dao_update_job(job)
if not service.active: if not service.active:
job.job_status = JOB_STATUS_CANCELLED job.job_status = JOB_STATUS_CANCELLED
dao_update_job(job) dao_update_job(job)
@@ -81,10 +85,6 @@ def process_job(job_id, sender_id=None):
if __sending_limits_for_job_exceeded(service, job, job_id): if __sending_limits_for_job_exceeded(service, job, job_id):
return return
job.job_status = JOB_STATUS_IN_PROGRESS
job.processing_started = start
dao_update_job(job)
recipient_csv, template, sender_id = get_recipient_csv_and_template_and_sender_id(job) recipient_csv, template, sender_id = get_recipient_csv_and_template_and_sender_id(job)
current_app.logger.info("Starting job {} processing {} notifications".format(job_id, job.notification_count)) current_app.logger.info("Starting job {} processing {} notifications".format(job_id, job.notification_count))