From 4d6358b0e7a14ec5f89e85aaa895b32cfebfdae9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 7 Dec 2023 10:22:50 -0500 Subject: [PATCH] queue the process instance AFTER unlocking it, do not set celery worker concurrency to 12, log already locked error in celery workers for debugging --- spiffworkflow-backend/bin/start_celery_worker | 2 +- .../celery_tasks/process_instance_task.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-backend/bin/start_celery_worker b/spiffworkflow-backend/bin/start_celery_worker index 1ea431c5b..8eefaf6ea 100755 --- a/spiffworkflow-backend/bin/start_celery_worker +++ b/spiffworkflow-backend/bin/start_celery_worker @@ -10,4 +10,4 @@ set -o errtrace -o errexit -o nounset -o pipefail export SPIFFWORKFLOW_BACKEND_CELERY_ENABLED=true export SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER_IN_CREATE_APP=false -poetry run celery -A src.spiffworkflow_backend.background_processing.celery_worker worker --loglevel=info -c 12 +poetry run celery -A src.spiffworkflow_backend.background_processing.celery_worker worker --loglevel=info diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task.py b/spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task.py index f10b4ff58..f080eb0ac 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task.py @@ -38,10 +38,13 @@ def celery_task_process_instance_run(process_instance_id: int, task_guid: str | future_task.completed = True db.session.add(future_task) db.session.commit() - if task_runnability == TaskRunnability.has_ready_tasks: - queue_process_instance_if_appropriate(process_instance) - except ProcessInstanceIsAlreadyLockedError: - pass + if task_runnability == TaskRunnability.has_ready_tasks: + queue_process_instance_if_appropriate(process_instance) + except ProcessInstanceIsAlreadyLockedError as exception: + current_app.logger.info( + f"Could not run process instance with worker: {current_app.config['PROCESS_UUID']} - {proc_index}. Error was:" + f" {str(exception)}" + ) except Exception as e: db.session.rollback() # in case the above left the database with a bad transaction error_message = (