Synchronize read and modification of @reserved_connections #6398
Synchronize read and modification of @reserved_connections #6398tenderlove merged 1 commit intorails:masterfrom
Conversation
…oid concurrency error.
|
/cc @tenderlove |
Synchronize read and modification of @reserved_connections
Synchronize read and modification of @reserved_connections
|
We are using the activerecord 3.2.6 gem and still hitting the same issue: Completed 200 OK in 109ms (Views: 109.0ms | ActiveRecord: 0.0ms) |
|
We're seeing this error as well, running jruby 1.7.1 and activerecord-jdbcmssql-adapter |
I am running JRuby 1.6.7 (1.6.6 locally) on Glassfishv3, OpenJDK. I am running a Rack
application that uses ActiveRecord 3.0.12 and/or 3.2.3. Glassfish
maintains a thread pool which it uses to service HTTP requests in a
multithreaded fashion. I am running into concurrency problems.
I have created a small JRuby-only test script that, at least on my
machine, reliably triggers the error. The script sets up active
record and then in a thread pool with 32 threads acquires and releases
connections from the connection pool.
With activerecord 3.2.3 and master (2012-05-19) I see the following error:
After applying my patch, I do not get the concurrency error. I am
also able to run the test suite for sqlite3 and postgresql.
After this patch, I do get another error with connection timeouts that
I am also seeing on my Glassfish system:
I believe it happens because the connection pool queue does not grant
a newly available connection to the first waiter in the queue. But
I'll leave for a future bug report; I'm yet not sure if ActiveRecord
or JRuby is at fault.
Here is the test script. The expected output is nothing. It prints
any exceptions that are raised. It runs for a long time, and may or
may not be able to reproduce the concurrency error, but on my system
it does reproduce it reliably. I'm not sure how to turn this script into a useful unit test,
mostly since it needs to run for a "long time" to even trigger the bug.
Any suggestions?
Executed like this:
The Gemfile:
The script itself: