11 Jan 2013 sness   » (Journeyer)

How our users exploited concurrency and how we fixed it - Evil Trout's Blog

How our users exploited concurrency and how we fixed it - Evil Trout's Blog: "# Keep everything in a database transaction
Player.transaction do

# Find the player's current goal
goal = player.goal

# Make sure we don't reward goals that have been already been completed
unless goal.completed?
goal.update_column :completed, true
player.increment!(:score, goal.score)
end

end
After much headdesking, I eventually discovered that the above code is not safe under concurrency."

'via Blog this'

Syndicated 2013-01-11 18:20:00 from sness

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!