Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

queue_processors: Generalize gating of opt-in dedicated queues.

Aman Agrawalb71c52ad094d
diff --git a/puppet/zulip/manifests/app_frontend_base.pp b/puppet/zulip/manifests/app_frontend_base.pp
index d0317b9932f..e6ff589be36 100644
--- a/puppet/zulip/manifests/app_frontend_base.pp
+++ b/puppet/zulip/manifests/app_frontend_base.pp
@@ -165,12 +165,13 @@ class zulip::app_frontend_base {
'user_activity',
'user_activity_interval',
]
- # Soft reactivations normally share the deferred_work queue; larger
- # servers can opt into a dedicated queue (and worker process) for them.
- $queues = zulipconf('application_server', 'dedicated_soft_reactivation_queue', false) ? {
- true => $base_queues + ['soft_reactivation'],
- default => $base_queues,
+ # Larger servers can opt into dedicated queues (and worker processes)
+ # for some deferred_work jobs.
+ $soft_reactivation_queue = zulipconf('application_server', 'dedicated_soft_reactivation_queue', false) ? {
+ true => ['soft_reactivation'],
+ default => [],
}
+ $queues = $base_queues + $soft_reactivation_queue
if $zulip::common::total_memory_mb > 24000 {
$uwsgi_default_processes = 16
diff --git a/zerver/worker/deferred_work.py b/zerver/worker/deferred_work.py
index e347873652f..7928ee38c22 100644
--- a/zerver/worker/deferred_work.py
+++ b/zerver/worker/deferred_work.py
@@ -32,6 +32,11 @@ class DeferredWorker(QueueProcessingWorker):
thread from the Django worker that initiated it (E.g. so we that
can provide a low-latency HTTP response or avoid risk of request
timeouts for an operation that could in rare cases take minutes).
+
+ A server can route some of these event types to a dedicated queue via
+ a dedicated_*_queue setting in zulip.conf. Their handlers here are
+ still needed, as the default path, and to process any events queued
+ here before the server opted in.
"""
# Because these operations have no SLO, and can take minutes,
@@ -83,13 +88,6 @@ class DeferredWorker(QueueProcessingWorker):
logger.info("Processing reupload_realm_emoji event for realm %s", realm.id)
handle_reupload_emojis_event(realm, logger)
elif event["type"] == "soft_reactivate":
- # Soft reactivations are normally enqueued here. A server can
- # opt into a dedicated soft_reactivation queue via the
- # dedicated_soft_reactivation_queue setting; even then, do not
- # remove this handler. It remains the default path, and it
- # drains any soft_reactivate events already in this queue when
- # that option is enabled -- stale deferred_work events can
- # linger across upgrades for a long time.
logger.info(
"Starting soft reactivation for user_profile_id %s",
event["user_profile_id"],
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py
index de3065a4248..ee643c51d8b 100644
--- a/zerver/worker/queue_processors.py
+++ b/zerver/worker/queue_processors.py
@@ -32,13 +32,12 @@ def get_active_worker_queues(only_test_queues: bool = False) -> list[str]:
for module_info in pkgutil.iter_modules(zerver.worker.__path__, "zerver.worker."):
importlib.import_module(module_info.name)
- queues = [
+ opt_in_queue_enabled = {
+ "soft_reactivation": settings.DEDICATED_SOFT_REACTIVATION_QUEUE,
+ }
+ return [
queue_name
for queue_name in worker_classes
if bool(queue_name in test_queues) == only_test_queues
+ and opt_in_queue_enabled.get(queue_name, True)
]
- if not settings.DEDICATED_SOFT_REACTIVATION_QUEUE:
- # Soft reactivations share the deferred_work queue unless a server
- # opts into a dedicated queue, so its worker is not run otherwise.
- queues = [queue_name for queue_name in queues if queue_name != "soft_reactivation"]
- return queues