I am not able to reproduce the error in my app that embeds Rails 2.2
with
JRuby 1.2.
However, looking at your stack trace, you seems to be spawning thread
when
handling a http request. Are you sure that that is what you intended?
From
what I understand, it is not advisable to spawn threads from a request
handler, because the connection and all the states are managed by the
container, so when your request handler returns, the container may
either
reuse the connection, or close it.
To see if this is the problem, wait on the new thread that you created
before
returning from your some_method. If the problem goes away, then the
issue is
most likely because you are using a connection that the container
thought you
have relinquished.
Peter
From: Ikai L. [mailto:[email protected]]
Sent: Monday, March 16, 2009 1:09 PM
To: [email protected]
Subject: Re: [jruby-user] Using Thread.new and performing ActiveRecord
operations causes occasional “Connection.close” exceptions
Attached is an example stack trace from our test environment where we
have
reproduced the error.
On 3/16/09 11:02 AM, “LinkedIn Corporation” [email protected] wrote:
Has anyone seen this? Here’s an example of what I’m talking about:
def some_method
Thread.new do
1000.times { Model.create :field => value }
end
end
The offending code has been rolled back, but while it was running it was
causing exceptions to be thrown intermittently stating that
“Connection.close() has already been called”. Also – I’ve seen other
exceptions stating that a database connection could not be acquired.
Increasing pool size gave us some breathing room there but doesn’t seem
like a
fix.
Does anyone have an explanation of how thread pooling actually works in
Rails
2.2? I feel like I’m cargo culting here and it’s resulting in problems
in
production.
Ikai
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email