Here's the quiz of the day: Can you find the exclusive lock in this code?
(hint: it begins on line 2, and ends on line 36)
It seemed reasonable that ActiveRecord.allow_currency would make my application be able to run concurrent queries. Well, that's what I thought :) Until I had discovered my 6 threads (which properly formed 6 new connections to the database) were still executing queries serially, instead of in parallel! When investigating what the hold up was, I found my culprit: Ruby 1.8's green threads lose control when you run native C functions, well at least Mysql#query anyways.
So, note to self and world: any time you run a native function that takes a long time, look forward to a big, exclusive lock down.
All the more reason I'm excited for Ruby 1.9's native threads
So, web, do you know if there's a way to "poll" ruby's thread scheduler while in a native C function while waiting for some other task to finish?