actions: Use 'durable=True' in outermost transaction.atomic block.

We used 'savepoint=False' in #31169 which was prior to our discussion
in CZO to use 'durable=True' instead.

This commit makes changes to use 'durable=True' in the outermost
transaction.atomic block.
This commit is contained in:
Prakhar Pratyush 2024-09-03 16:53:08 +05:30 committed by Tim Abbott
parent d7761f7163
commit a2ff4f52c4
3 changed files with 4 additions and 4 deletions

View File

@ -12,13 +12,13 @@ def notify_alert_words(user_profile: UserProfile, words: Sequence[str]) -> None:
send_event_on_commit(user_profile.realm, event, [user_profile.id])
@transaction.atomic(savepoint=False)
@transaction.atomic(durable=True)
def do_add_alert_words(user_profile: UserProfile, alert_words: Iterable[str]) -> None:
words = add_user_alert_words(user_profile, alert_words)
notify_alert_words(user_profile, words)
@transaction.atomic(savepoint=False)
@transaction.atomic(durable=True)
def do_remove_alert_words(user_profile: UserProfile, alert_words: Iterable[str]) -> None:
words = remove_user_alert_words(user_profile, alert_words)
notify_alert_words(user_profile, words)

View File

@ -93,7 +93,7 @@ def do_schedule_messages(
scheduled_messages.append((scheduled_message, send_request))
with transaction.atomic():
with transaction.atomic(durable=True):
ScheduledMessage.objects.bulk_create(
[scheduled_message for scheduled_message, ignored in scheduled_messages]
)

View File

@ -7,7 +7,7 @@ from zerver.models import UserProfile
from zerver.tornado.django_api import send_event_on_commit
@transaction.atomic(savepoint=False)
@transaction.atomic(durable=True)
def do_update_user_status(
user_profile: UserProfile,
away: bool | None,