This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
Race condition in assigning coupons #415
Labels
bug-report
Unverified user submitted bug that needs verification
help-wanted
Looking for help from open source contributors
We assign coupons in memory: https://github.com/raise-dev/hacktoberfest/blob/b6e5099f0e1486e81612d2c2e29ef334c27f6e7c/app/services/coupon_service.rb#L8-L14
And rely on Rails optimistic locking to ensure that the same coupon is not assigned to multiple users.
There were a few cases where users reported having received coupons that were already used. Upon inspection, a small number of coupons had
lock_version
greater than1
meaning they were assigned multiple times.This must be some sort of race condition that occurs under high concurrency.
It's not impacting any more users for this year, but will need to be addressed.
The text was updated successfully, but these errors were encountered: