On 23 Apr 2008, at 10:25, Michael Koziarski wrote:

>
>> Are there any claims as to whether Dependencies is thread safe? I was
>> working on an odd startup problem one of our scripts has and it turns
>> out that there seems to be a race condition:
>
> We actually discussed this in #rails-contrib earlier today.   As it
> stands there are absolutely no locks or synchronisation in
> dependencies.rb, so it's completely thread-dangerous.  There are a
> couple of things we could do:
>
Thanks for the confirmation.

> 1) Have a giant 'doing dependencies lock
>
> By wrapping a big lock around load_missing_constant and friends so
> only one thread goes about creating classes at any given time.  All
> the other threads would have to wait for that lock to be released.
> This would probably be a little difficult to test, but not too
> difficult.
>
And loading constants isn't something you spent a lot of time doing  
(except perhaps in dev mode) so it shouldn't be much of a bottleneck.
The experiments I did around forcing a systematic failure could  
conceivably be used to write a failing test for the current version of  
rails. I might have a poke, although there are a few other things that  
I've been meaning to tackle that I haven't got round to yet.

Fred


> 2) Have an alternative Dependencies mode.
>
> Just load everything up front before we start dispatching requests.
>
> Both these options were discussed in #9155 like tarmo said.  Rather
> than Thread#exclusive we could use some specific mutexes so other
> threads can go about their other business.  Any takers?
>
>
>
> -- 
> Cheers
>
> Koz
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to