aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-06-05 17:01:57 -0400
committerGitHub <noreply@github.com>2019-06-05 17:01:57 -0400
commitc4d8e057c540dd0ba424dcc5203db1c945b4b412 (patch)
treec1910ea78f5d477669620a201e7509401e3a6a96 /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
parentf166a01b4bfca7d32428095670a271d0771db797 (diff)
parent49b6b211a922f73d0b083e7e4d2f0a91bd44da90 (diff)
downloadrails-c4d8e057c540dd0ba424dcc5203db1c945b4b412.tar.gz
rails-c4d8e057c540dd0ba424dcc5203db1c945b4b412.tar.bz2
rails-c4d8e057c540dd0ba424dcc5203db1c945b4b412.zip
Merge pull request #36371 from eileencodes/move-schema-cache-to-pool
Move schema cache to pool
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index bf0bb84c93..57a8e7ad98 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -78,7 +78,7 @@ module ActiveRecord
SIMPLE_INT = /\A\d+\z/
attr_accessor :pool
- attr_reader :schema_cache, :visitor, :owner, :logger, :lock, :prepared_statements, :prevent_writes
+ attr_reader :visitor, :owner, :logger, :lock, :prepared_statements, :prevent_writes
alias :in_use? :owner
set_callback :checkin, :after, :enable_lazy_transactions!
@@ -114,9 +114,8 @@ module ActiveRecord
@instrumenter = ActiveSupport::Notifications.instrumenter
@logger = logger
@config = config
- @pool = nil
+ @pool = ActiveRecord::ConnectionAdapters::NullPool.new
@idle_since = Concurrent.monotonic_time
- @schema_cache = SchemaCache.new self
@quoted_column_names, @quoted_table_names = {}, {}
@prevent_writes = false
@visitor = arel_visitor
@@ -206,9 +205,13 @@ module ActiveRecord
@owner = Thread.current
end
+ def schema_cache
+ @pool.get_schema_cache(self)
+ end
+
def schema_cache=(cache)
cache.connection = self
- @schema_cache = cache
+ @pool.set_schema_cache(cache)
end
# this method must only be called while holding connection pool's mutex
@@ -487,6 +490,9 @@ module ActiveRecord
#
# Prevent @connection's finalizer from touching the socket, or
# otherwise communicating with its server, when it is collected.
+ if schema_cache.connection == self
+ schema_cache.connection = nil
+ end
end
# Reset the state of this connection, directing the DBMS to clear