delete_message_backend: Add `durable=True` to the outermost transaction.

This commit adds 'durable=True' to the outermost transaction
in 'delete_message_backend'.

It also adds 'savepoint=False' to inner transaction.atomic
decorator to avoid creating savepoint.

This is as a part of our plan to explicitly mark all the
transaction.atomic decorators with either 'savepoint=False' or
'durable=True' as required.

* 'savepoint=True' is used in special cases.
This commit is contained in:
Prakhar Pratyush 2024-11-01 17:13:55 +05:30 committed by Tim Abbott
parent 0fb5657131
commit 3d597bb9b0
2 changed files with 3 additions and 2 deletions

View File

@ -141,7 +141,7 @@ def run_archiving(
message_count = 0
while True:
start_time = time.time()
with transaction.atomic():
with transaction.atomic(savepoint=False):
archive_transaction = ArchiveTransaction.objects.create(type=type, realm=realm)
new_chunk = move_rows(
Message,
@ -396,6 +396,7 @@ def archive_stream_messages(
logger.info("Done. Archived %s messages.", message_count)
@transaction.atomic(durable=True)
def archive_messages(chunk_size: int = MESSAGE_BATCH_SIZE) -> None:
logger.info("Starting the archiving process with chunk_size %s", chunk_size)

View File

@ -167,7 +167,7 @@ def validate_can_delete_message(user_profile: UserProfile, message: Message) ->
return
@transaction.atomic
@transaction.atomic(durable=True)
@typed_endpoint
def delete_message_backend(
request: HttpRequest,