From 315576b0de8fff64b8c659fd441696c09400f101 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sun, 12 Jul 2026 21:39:09 -0400 Subject: [PATCH 1/3] feat(backend): reduce RQ worker registry sweep verbosity and frequency Generated-By: PostHog Code --- backend/handler/rq_worker.py | 25 +++++++++++++++++++++++++ docker/init_scripts/init | 4 ++++ entrypoint.sh | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 backend/handler/rq_worker.py diff --git a/backend/handler/rq_worker.py b/backend/handler/rq_worker.py new file mode 100644 index 000000000..62ef6d9fc --- /dev/null +++ b/backend/handler/rq_worker.py @@ -0,0 +1,25 @@ +import logging +from typing import Any + +from rq import Worker + + +class _DropRegistryCleanupFilter(logging.Filter): + """Drops RQ's periodic "cleaning registries for queue" INFO line. + + The maintenance sweep still runs (crash recovery for orphaned jobs, TTL + reaping, stale worker pruning); only its log record is suppressed so it + does not flood logs on every maintenance interval. + """ + + def filter(self, record: logging.LogRecord) -> bool: + return "cleaning registries for queue" not in record.getMessage() + + +class RomMWorker(Worker): + """RQ worker that silences the noisy registry-cleanup log line.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + if not any(isinstance(f, _DropRegistryCleanupFilter) for f in self.log.filters): + self.log.addFilter(_DropRegistryCleanupFilter()) diff --git a/docker/init_scripts/init b/docker/init_scripts/init index e94fd05a7..9855accbf 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -233,8 +233,12 @@ start_bin_rq_worker() { fi # Set PYTHONPATH so RQ can find the tasks module + # Sweep registries hourly instead of every ~10 min, using a worker class that + # drops the noisy per-sweep "cleaning registries for queue" log line. PYTHONPATH="/backend:${PYTHONPATH-}" rq worker \ --path /backend \ + --worker-class handler.rq_worker.RomMWorker \ + --maintenance-interval 3600 \ --pid /tmp/rq_worker.pid \ --url "${redis_url}" \ --results-ttl "${TASK_RESULT_TTL:-86400}" \ diff --git a/entrypoint.sh b/entrypoint.sh index c60fc94c9..22675d357 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,8 +69,12 @@ else fi # Set PYTHONPATH so RQ can find the tasks module +# Sweep registries hourly instead of every ~10 min, using a worker class that +# drops the noisy per-sweep "cleaning registries for queue" log line. PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \ --path /app/backend \ + --worker-class handler.rq_worker.RomMWorker \ + --maintenance-interval 3600 \ --pid /tmp/rq_worker.pid \ --url "${REDIS_URL}" \ --logging_level "${LOGLEVEL:-INFO}" \ From 30ac589461c5a885b8be319228bc0ae2f80edf8d Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 13 Jul 2026 06:47:19 -0400 Subject: [PATCH 2/3] fix(backend): make registry-cleanup log filter case-insensitive Match the cleanup line regardless of casing so it stays filtered if a future RQ release changes the message capitalization. Generated-By: PostHog Code Task-Id: 4b52504d-3f92-4114-b4aa-887a4e6a50f9 --- backend/handler/rq_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/handler/rq_worker.py b/backend/handler/rq_worker.py index 62ef6d9fc..60613a01c 100644 --- a/backend/handler/rq_worker.py +++ b/backend/handler/rq_worker.py @@ -13,7 +13,7 @@ class _DropRegistryCleanupFilter(logging.Filter): """ def filter(self, record: logging.LogRecord) -> bool: - return "cleaning registries for queue" not in record.getMessage() + return "cleaning registries for queue" not in record.getMessage().lower() class RomMWorker(Worker): From 23d724f447cf11a8cb4b50f0d0b41f37509f7b1a Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Wed, 15 Jul 2026 20:02:49 -0400 Subject: [PATCH 3/3] fix(backend): keep default RQ maintenance interval for prompt scan recovery The registry-cleanup log noise is already suppressed by the RomMWorker log filter, so the hourly maintenance interval was unnecessary and delayed pruning of orphaned STARTED jobs and stale workers. The watcher's Worker.all() scan dedupe relies on that pruning, so restore the default (~10 min) cadence. Generated-By: PostHog Code Task-Id: 78c8b2f8-2b03-443f-aa4c-8867c1259f2a --- docker/init_scripts/init | 9 +++++---- entrypoint.sh | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docker/init_scripts/init b/docker/init_scripts/init index 9855accbf..62cce1c36 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -232,13 +232,14 @@ start_bin_rq_worker() { redis_url="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}" fi - # Set PYTHONPATH so RQ can find the tasks module - # Sweep registries hourly instead of every ~10 min, using a worker class that - # drops the noisy per-sweep "cleaning registries for queue" log line. + # Set PYTHONPATH so RQ can find the tasks module. + # Use a worker class that drops the noisy per-sweep "cleaning registries for + # queue" log line. The maintenance interval keeps its default (~10 min) so + # orphaned STARTED jobs and stale workers are still pruned promptly, which the + # watcher's Worker.all() scan dedupe relies on. PYTHONPATH="/backend:${PYTHONPATH-}" rq worker \ --path /backend \ --worker-class handler.rq_worker.RomMWorker \ - --maintenance-interval 3600 \ --pid /tmp/rq_worker.pid \ --url "${redis_url}" \ --results-ttl "${TASK_RESULT_TTL:-86400}" \ diff --git a/entrypoint.sh b/entrypoint.sh index 22675d357..d14bfa181 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -68,13 +68,14 @@ else REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}" fi -# Set PYTHONPATH so RQ can find the tasks module -# Sweep registries hourly instead of every ~10 min, using a worker class that -# drops the noisy per-sweep "cleaning registries for queue" log line. +# Set PYTHONPATH so RQ can find the tasks module. +# Use a worker class that drops the noisy per-sweep "cleaning registries for +# queue" log line. The maintenance interval keeps its default (~10 min) so +# orphaned STARTED jobs and stale workers are still pruned promptly, which the +# watcher's Worker.all() scan dedupe relies on. PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \ --path /app/backend \ --worker-class handler.rq_worker.RomMWorker \ - --maintenance-interval 3600 \ --pid /tmp/rq_worker.pid \ --url "${REDIS_URL}" \ --logging_level "${LOGLEVEL:-INFO}" \