aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-11-29 15:04:41 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-11-29 15:04:41 -0800
commit0e2477b602b3aa5b66c849d19737a8b66c73f633 (patch)
tree2881fbaee090bc9472210d0554799867f319a20f /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parent29d2040b2992c112ca475a7a56bcd7f2016252ce (diff)
downloadrails-0e2477b602b3aa5b66c849d19737a8b66c73f633.tar.gz
rails-0e2477b602b3aa5b66c849d19737a8b66c73f633.tar.bz2
rails-0e2477b602b3aa5b66c849d19737a8b66c73f633.zip
Automatic closure of connections in threads is deprecated. For example
the following code is deprecated: Thread.new { Post.find(1) }.join It should be changed to close the database connection at the end of the thread: Thread.new { Post.find(1) Post.connection.close }.join Only people who spawn threads in their application code need to worry about this change.
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.rb8
1 files changed, 7 insertions, 1 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 656073b47a..d127b3ebd8 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -190,7 +190,13 @@ module ActiveRecord
t.alive?
}.map { |thread| thread.object_id }
keys.each do |key|
- checkin @reserved_connections[key]
+ conn = @reserved_connections[key]
+ ActiveSupport::Deprecation.warn(<<-eowarn) if conn.in_use?
+Database connections will not be closed automatically, please close your
+database connection at the end of the thread by calling `close` on your
+connection. For example: ActiveRecord::Base.connection.close
+ eowarn
+ checkin conn
@reserved_connections.delete(key)
end
end