queue: Rename queue_json_publish to queue_json_publish_rollback_unsafe.

This commit renames the 'queue_json_publish' function to
'queue_json_publish_rollback_unsafe' to reflect the fact that it doesn't
wait for the db transaction (within which it gets called, if any)
to commit and sends event irrespective of commit or rollback.

In most of the cases we don't want to send event in the case of
rollbacks, so the caller should be aware that calling the function
directly is rollback unsafe.

Fixes part of #30489.
This commit is contained in:
Prakhar Pratyush
2024-12-06 12:14:03 +05:30
committed by Tim Abbott
parent 1847086044
commit 3bad36ef8c
24 changed files with 63 additions and 53 deletions

View File

@@ -14,7 +14,7 @@ from typing_extensions import override
from urllib3.util import Retry
from zerver.lib.partial import partial
from zerver.lib.queue import queue_json_publish
from zerver.lib.queue import queue_json_publish_rollback_unsafe
from zerver.models import Client, Realm, UserProfile
from zerver.tornado.sharding import (
get_realm_tornado_ports,
@@ -201,7 +201,7 @@ def send_event_rollback_unsafe(
port_user_map[get_user_id_tornado_port(realm_ports, user_id)].append(user)
for port, port_users in port_user_map.items():
queue_json_publish(
queue_json_publish_rollback_unsafe(
notify_tornado_queue_name(port),
dict(event=event, users=port_users),
partial(send_notification_http, port),