[Backgroundrb-devel] Impossible to get stable?

Ezra Zygmuntowicz 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  
> errors:
> #<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

Hey Ben-

	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...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060819/d73ba4a7/attachment-0001.html 

More information about the Backgroundrb-devel mailing list