create_user: Add 'durable=True' to the outermost transaction.

We need to specify savepoint=False explicitly in the one subroutine
that already specifies a transaction.
This commit is contained in:
Prakhar Pratyush 2024-10-28 14:46:42 +05:30 committed by Tim Abbott
parent 50674a7a28
commit 555ac613ac
2 changed files with 71 additions and 73 deletions

View File

@ -487,6 +487,7 @@ def notify_created_bot(user_profile: UserProfile) -> None:
send_event_on_commit(user_profile.realm, event, bot_owner_user_ids(user_profile))
@transaction.atomic(durable=True)
def do_create_user(
email: str,
password: str | None,
@ -516,7 +517,6 @@ def do_create_user(
if settings.BILLING_ENABLED:
from corporate.lib.stripe import RealmBillingSession
with transaction.atomic():
user_profile = create_user(
email=email,
password=password,
@ -556,9 +556,7 @@ def do_create_user(
# If this user just created a realm, make sure they are
# properly tagged as the creator of the realm.
realm_creation_audit_log = (
RealmAuditLog.objects.filter(
event_type=AuditLogEventType.REALM_CREATED, realm=realm
)
RealmAuditLog.objects.filter(event_type=AuditLogEventType.REALM_CREATED, realm=realm)
.order_by("id")
.last()
)

View File

@ -229,7 +229,7 @@ def send_welcome_bot_response(send_request: SendMessageRequest) -> None:
)
@transaction.atomic
@transaction.atomic(savepoint=False)
def send_initial_realm_messages(realm: Realm) -> None:
# Sends the initial messages for a new organization.
#