Every app with points has a line like this somewhere:
learner . Points += 50 ; await db . SaveChangesAsync ( ) ;
Enter fullscreen mode
Exit fullscreen mode
It looks harmless. Then real traffic arrives:
The mobile app times out and retries "lesson completed". The learner gets 100 points.
A message queue delivers the same event twice , which at-least-once delivery is allowed to do. The learner gets 100 points again.
The learner double-taps "Redeem" on the last tutor session. Two requests both read "1 left", and both succeed.
Staff cancel a redemption, the request is retried, and the points are refunded twice .
None of these is unusual. Once points can buy something they behave like money, and code that handles money needs to be exact.
I'm adding a rewards programme to StrideWell, the platform for gyms and coaches I'm building. Members earn points for sessions and streaks, and spend them on rewards their gym pays for.…