aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
diff options
context:
space:
mode:
authorPatrick Mahoney <pat@polycrystal.org>2012-05-25 13:19:19 -0500
committerPatrick Mahoney <pat@polycrystal.org>2012-05-25 13:19:19 -0500
commit02b233556377e9c40f17e2142d60cd82976ca9ea (patch)
tree2566e81a190f9bac2f1de2a7fce1fd1ace826d85 /activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
parent40cfcacca4c12a74556bfda3bded979df43434eb (diff)
downloadrails-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/abstract_adapter_test.rb')
-rw-r--r--activerecord/test/cases/connection_adapters/abstract_adapter_test.rb2
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