From bde446ea9bbeebcb56394af6f7605179ba09ed37 Mon Sep 17 00:00:00 2001 From: rkuo-danswer Date: Thu, 24 Oct 2024 14:49:18 -0700 Subject: [PATCH] can't add to primary_worker_locks if it doesn't exist (#2903) * can't add to primary_worker_locks if it doesn't exist * move init --- backend/danswer/background/celery/apps/primary.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/danswer/background/celery/apps/primary.py b/backend/danswer/background/celery/apps/primary.py index d86f0d60fe4..23e25fa92b8 100644 --- a/backend/danswer/background/celery/apps/primary.py +++ b/backend/danswer/background/celery/apps/primary.py @@ -78,6 +78,8 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None: logger.info("Running as the primary celery worker.") + sender.primary_worker_locks = {} + # This is singleton work that should be done on startup exactly once # by the primary worker tenant_ids = get_all_tenant_ids() @@ -106,6 +108,7 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None: logger.error("Primary worker lock: Acquire failed!") raise WorkerShutdown("Primary worker lock could not be acquired!") + # tacking on our own user data to the sender sender.primary_worker_locks[tenant_id] = lock # As currently designed, when this worker starts as "primary", we reinitialize redis