mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
soft_deactivate: Log and continue on failure to catch up a user.
There exists a logic bug (see #18236) which causes duplicate usermessage rows to be inserted. Currently, this stops catch-up for all users. Catch and record the exception for each affected user, so we at least make catch-up progress on other users.
This commit is contained in:
committed by
Tim Abbott
parent
6db454b252
commit
11177a40da
@@ -7,6 +7,7 @@ from django.conf import settings
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
from django.utils.timezone import now as timezone_now
|
from django.utils.timezone import now as timezone_now
|
||||||
|
from sentry_sdk import capture_exception
|
||||||
|
|
||||||
from zerver.lib.logging_util import log_to_file
|
from zerver.lib.logging_util import log_to_file
|
||||||
from zerver.models import (
|
from zerver.models import (
|
||||||
@@ -342,11 +343,18 @@ def do_soft_activate_users(users: List[UserProfile]) -> List[UserProfile]:
|
|||||||
|
|
||||||
def do_catch_up_soft_deactivated_users(users: List[UserProfile]) -> List[UserProfile]:
|
def do_catch_up_soft_deactivated_users(users: List[UserProfile]) -> List[UserProfile]:
|
||||||
users_caught_up = []
|
users_caught_up = []
|
||||||
|
failures = []
|
||||||
for user_profile in users:
|
for user_profile in users:
|
||||||
if user_profile.long_term_idle:
|
if user_profile.long_term_idle:
|
||||||
|
try:
|
||||||
add_missing_messages(user_profile)
|
add_missing_messages(user_profile)
|
||||||
users_caught_up.append(user_profile)
|
users_caught_up.append(user_profile)
|
||||||
|
except Exception: # nocoverage
|
||||||
|
capture_exception() # nocoverage
|
||||||
|
failures.append(user_profile) # nocoverage
|
||||||
logger.info("Caught up %d soft-deactivated users", len(users_caught_up))
|
logger.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
|
||||||
return users_caught_up
|
return users_caught_up
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user