[Backgroundrb-devel] Impossible to get stable?
ezmobius at gmail.com
Sun Aug 20 00:39:25 EDT 2006
On Aug 18, 2006, at 6:20 PM, Ben Johnson wrote:
> I have concluded that it is impossible to get this background
> process stable. I am out of ideas and could really use some help.
> Here is what I have:
> 50 workers, just running an infinite loop that constantly calls
> save! on a model. Keep in mind this is just for testing purposes. I
> catch all exceptions and put them in the log.
> I am tried setting allow_concurrency to true and false. Neither of
> them is stable. For both true and false I have got the following
> #<ActiveRecord::StatementInvalid: Mysql::Error: Lock wait timeout
> exceeded; try restarting transaction:
> #<ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has
> gone away:
> What have you found to be most stable? Setting allow concurrency to
> false and just putting a Mutex.synchronize object around all
> database calls? Or setting it true?
> Thank You,
> Ben Johnson
> E: bjohnson at contuitive.com
> O: 800-341-6826
> M: 817-229-4258
I feel your pain. I have come to the conclusion that ActiveRecord is
just not thread safe no matter what you do. My best suggestion is to
use either dbi or mysql bindings directly in your workers. These are
thread safe and while you would have to write some sql yourself, it
would solve your issue. I get the feeling that railscore is not very
interested in making rails thread safe at this point and pushing as
many db connections in as many threads as you are doing is more the
ActiveRecord can handle.
I know its not what you want to hear but its the situation we have
to deal with.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Backgroundrb-devel