fix(events): keep registration status reads nonblocking

This commit is contained in:
2026-10-01 13:35:17 +03:30
parent 962238c32c
commit f924fcc52e
16 changed files with 498 additions and 107 deletions

View File

@@ -18,7 +18,7 @@ from apps.payments.models import Payment, DiscountCode
from apps.events.models import Event, Registration
from apps.events.checkout import (
CHECKOUT_TIMEOUT,
expire_stale_registration_checkouts,
expire_user_registration_checkouts,
queue_checkout_reconciliation,
)
from apps.notifications.services import notify_user
@@ -316,8 +316,13 @@ def _ensure_checkout_attempt_can_be_reused(payment: Payment, *, now, allow_revie
def create_payment(request, payload: CreatePaymentIn):
idempotency_key = payload.idempotency_key or uuid4()
now = timezone.now()
expire_stale_registration_checkouts(now=now, event_id=payload.event_id)
with transaction.atomic():
event = get_object_or_404(
Event.objects.select_for_update(),
pk=payload.event_id,
is_deleted=False,
)
expire_user_registration_checkouts(event=event, user=request.auth, now=now)
# Serialize checkout creation for this event so concurrent taps cannot
# both create a new active attempt for the same user/event pair.
with transaction.atomic():