On Sun, Apr 20, 2008 at 6:39 PM, Michael Koziarski
<[EMAIL PROTECTED]> wrote:
>  This will be the biggest change,  we can do implicit checkout of a
>  connection when trying to access the database for the first time in a
>  thread, but implicit checkin seems to be asking for trouble.    We can
>  handle it for ActionController easily enough by checking the
>  connections back in after the request has been dispatched.

Agreed. Implicit check-in seems bad. Pratik suggested in
#rails-contrib that we might use a Dispatcher hook instead of a
controller filter, which makes sense. Get it out of the way of the
application code so it doesn't get touched inadvertently.

>  So my first thought is:
>
>  Foo.find(:first) # retrieves connection
>  Thread.new do
>   Foo.find(:first) # retrieves another
>   Bar.find(:first) # uses existing
>   ActiveRecord::Base.release_connection
>   Foo.find(:first) # retrieves another
>  end
>
>  With retrieving blocking until the connection is available.

I realized we might also be able to make
ActiveRecord::Base.transaction do its own checkout/checkin of the
connection. There will probably be more opportunities to optimize this
later too. For example, making ActiveRecord::Base.connection accept a
block and start to change places in the framework to use the block
form instead of the return the connection/implicit checkout version. I
haven't looked too closely to see what the potential is there, though.

/Nick

--~--~---------~--~----~------------~-------~--~----~
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