mirror of
https://github.com/pretix/pretix.git
synced 2026-05-16 17:03:58 +00:00
CartManager: use database NOW() for extend-while-valid to avoid race condition
This commit is contained in:
@@ -47,6 +47,7 @@ from django.core.exceptions import ValidationError
|
|||||||
from django.db import DatabaseError, transaction
|
from django.db import DatabaseError, transaction
|
||||||
from django.db.models import Count, Exists, IntegerField, OuterRef, Q, Value
|
from django.db.models import Count, Exists, IntegerField, OuterRef, Q, Value
|
||||||
from django.db.models.aggregates import Min
|
from django.db.models.aggregates import Min
|
||||||
|
from django.db.models.functions import Now
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.timezone import make_aware, now
|
from django.utils.timezone import make_aware, now
|
||||||
from django.utils.translation import (
|
from django.utils.translation import (
|
||||||
@@ -345,7 +346,7 @@ class CartManager:
|
|||||||
# We can extend the reservation of items which are not yet expired without risk
|
# We can extend the reservation of items which are not yet expired without risk
|
||||||
if self._expiry > self.real_now_dt:
|
if self._expiry > self.real_now_dt:
|
||||||
self.num_extended_positions += self.positions.filter(
|
self.num_extended_positions += self.positions.filter(
|
||||||
expires__gt=self.real_now_dt, expires__lt=self._expiry,
|
expires__gt=Now(), expires__lt=self._expiry,
|
||||||
).update(
|
).update(
|
||||||
expires=self._expiry,
|
expires=self._expiry,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user