aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index d4649102df..6cb97bc550 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -54,8 +54,11 @@ module ActiveRecord
# your database connection configuration:
#
# * +pool+: number indicating size of connection pool (default 5)
- # * +wait_timeout+: number of seconds to block and wait for a connection
- # before giving up and raising a timeout error (default 5 seconds).
+ # * +checkout _timeout+: number of seconds to block and wait for a
+ # connection before giving up and raising a timeout error
+ # (default 5 seconds). ('wait_timeout' supported for backwards
+ # compatibility, but conflicts with key used for different purpose
+ # by mysql2 adapter).
class ConnectionPool
include MonitorMixin
@@ -77,7 +80,10 @@ module ActiveRecord
@reserved_connections = {}
@queue = new_cond
- @timeout = spec.config[:wait_timeout] || 5
+ # 'wait_timeout', the backward-compatible key, conflicts with spec key
+ # used by mysql2 for something entirely different, checkout_timeout
+ # preferred to avoid conflict and allow independent values.
+ @timeout = spec.config[:checkout_timeout] || spec.config[:wait_timeout] || 5
# default max pool size to 5
@size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
@@ -110,7 +116,7 @@ module ActiveRecord
# #release_connection releases the connection-thread association
# and returns the connection to the pool.
def release_connection(with_id = current_connection_id)
- conn = @reserved_connections.delete(with_id)
+ conn = synchronize { @reserved_connections.delete(with_id) }
checkin conn if conn
end