News for hackers. Stuff that matters.
Re:EA “Gives Away” 1000s Of Free Games Due To No Server-Side... by ams6110 on Sunday October 14, 2012 @03:48PM (#4652384)
It really isn't as easy as it sounds, is it? A better approach might be to UPDATE promo_codes SET used = 1 WHERE ... AND used = 0, and then check that one update occurred. Or if your db supports it, SELECT ... FOR UPDATE OF ... and then update if the code is not yet used. You want the check and the update to occur atomically. And this varies depending on databases, for example in Oracle even if you explicitly begin a transaction, a select does not lock the row (unless you specify FOR UPDATE OF) so if you do the check and the update in separate statements, you still have a race condition).
Re:EA “Gives Away” 1000s Of Free Games Due To No Server-Side... by Negitivefrags on Sunday October 14, 2012 @04:24PM (#4652526)
I actually wasn't personally involved in the solution, but I believe that we went with something involving SELECT FOR UPDATE.