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

@@ -6,7 +6,7 @@ from django.core.management.base import CommandParser
from typing_extensions import override
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.queue import SimpleQueueClient, queue_json_publish
from zerver.lib.queue import SimpleQueueClient, queue_json_publish_rollback_unsafe
from zerver.worker.test import BatchNoopWorker, NoopWorker
@@ -71,7 +71,7 @@ class Command(ZulipBaseCommand):
for i in range(1, reps + 1):
worker.consumed = 0
timeit(
lambda: queue_json_publish(queue_name, {}),
lambda: queue_json_publish_rollback_unsafe(queue_name, {}),
number=count,
)
duration = timeit(worker.start, number=1)