Re:How our users exploited concurrency and how we fixed it
by EvilTrout on Friday January 11, 2013 @12:04PM
(#5043576)
facepalm
I forgot a very important part of the query:
row_count = Goal.update_all "completed = true", ["player_id = ? AND completed = false", player.id]
If you update where completed = false, the rowcount will only be 1 when the update works.
(I've updated the blog post.)
There are numerous ways around that, from less fancy to really fancy.
There's a few more, but I ran out of steam typing ;) Yay, Postgres!