Skip to content

Commit

Permalink
server/discount: raise redemption lock timeout to handle slow Stripe …
Browse files Browse the repository at this point in the history
…requests
  • Loading branch information
frankie567 committed Dec 24, 2024
1 parent e640b9a commit 543767d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/polar/discount/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,11 @@ async def is_redeemable_discount(
async def redeem_discount(
self, session: AsyncSession, locker: Locker, discount: Discount
) -> AsyncIterator[DiscountRedemption]:
# The timeout is purposely set to 10 seconds, a high value.
# We've seen in the past Stripe payment requests taking more than 5 seconds,
# causing the lock to expire while waiting for the payment to complete.
async with locker.lock(
f"discount:{discount.id}", timeout=5, blocking_timeout=5
f"discount:{discount.id}", timeout=10, blocking_timeout=10
):
if not await self.is_redeemable_discount(session, discount):
raise DiscountNotRedeemableError(discount)
Expand Down

0 comments on commit 543767d

Please sign in to comment.