Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
soft_deactivation: Better logging on failures.
Alex Vandiverc6fd943a553e
diff --git a/zerver/lib/soft_deactivation.py b/zerver/lib/soft_deactivation.pyindex bf82a4c2c2f..8ce1fdd1c70 100644--- a/zerver/lib/soft_deactivation.py+++ b/zerver/lib/soft_deactivation.py@@ -4,12 +4,12 @@ from collections import defaultdictfrom collections.abc import Iterable, Sequencefrom typing import Any, TypedDict+import sentry_sdkfrom django.conf import settingsfrom django.db import transactionfrom django.db.models import Exists, F, Max, OuterRef, QuerySetfrom django.db.models.functions import Greatestfrom django.utils.timezone import now as timezone_now-from sentry_sdk import capture_exceptionfrom zerver.lib.logging_util import log_to_filefrom zerver.lib.queue import queue_event_on_commit@@ -369,12 +369,16 @@ def do_catch_up_soft_deactivated_users(users: Iterable[UserProfile]) -> list[Usefailures = []for user_profile in users:if user_profile.long_term_idle:- try:- add_missing_messages(user_profile)- users_caught_up.append(user_profile)- except Exception: # nocoverage- capture_exception() # nocoverage- failures.append(user_profile) # nocoverage+ with sentry_sdk.isolation_scope() as scope:+ scope.set_user({"id": str(user_profile.id)})+ try:+ add_missing_messages(user_profile)+ users_caught_up.append(user_profile)+ except Exception: # nocoverage+ logger.exception(+ "Failed to catch up %d@%s", user_profile.id, user_profile.realm.string_id+ ) # nocoverage+ failures.append(user_profile) # nocoveragelogger.info("Caught up %d soft-deactivated users", len(users_caught_up))if failures:logger.error("Failed to catch up %d soft-deactivated users", len(failures)) # nocoverage