diff options
author | Patrick Mahoney <pat@polycrystal.org> | 2012-05-25 13:19:19 -0500 |
---|---|---|
committer | Patrick Mahoney <pat@polycrystal.org> | 2012-05-25 13:19:19 -0500 |
commit | 02b233556377e9c40f17e2142d60cd82976ca9ea (patch) | |
tree | 2566e81a190f9bac2f1de2a7fce1fd1ace826d85 /activerecord/test/cases/connection_adapters | |
parent | 40cfcacca4c12a74556bfda3bded979df43434eb (diff) | |
download | rails-02b233556377e9c40f17e2142d60cd82976ca9ea.tar.gz rails-02b233556377e9c40f17e2142d60cd82976ca9ea.tar.bz2 rails-02b233556377e9c40f17e2142d60cd82976ca9ea.zip |
Make connection pool fair with respect to waiting threads.
The core of this fix is a threadsafe, fair Queue class. It is
very similar to Queue in stdlib except that it supports waiting
with a timeout.
The issue this solves is that if several threads are contending for
database connections, an unfair queue makes is possible that a thread
will timeout even while other threads successfully acquire and release
connections. A fair queue means the thread that has been waiting the
longest will get the next available connection.
This includes a few test fixes to avoid test ordering issues that
cropped up during development of this patch.
Diffstat (limited to 'activerecord/test/cases/connection_adapters')
-rw-r--r-- | activerecord/test/cases/connection_adapters/abstract_adapter_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb b/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb index 7dc6e8afcb..3e3d6e2769 100644 --- a/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb +++ b/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb @@ -36,7 +36,7 @@ module ActiveRecord def test_close pool = ConnectionPool.new(ConnectionSpecification.new({}, nil)) - pool.connections << adapter + pool.insert_connection_for_test! adapter adapter.pool = pool # Make sure the pool marks the connection in use |