Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2162: active_record_connection_pooling2.diff

File active_record_connection_pooling2.diff, 4.3 kB (added by anonymous, 3 years ago)
  • activerecord/test/fixtures/db_definitions/mysql.sql

    old new  
    188188CREATE TABLE `fk_test_has_fk` ( 
    189189  `id`    INTEGER NOT NULL PRIMARY KEY, 
    190190  `fk_id` INTEGER NOT NULL, 
    191  
     191  INDEX `fk_ind` (`fk_id`), 
    192192  FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`) 
    193193) TYPE=InnoDB; 
    194194 
  • activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb

    old new  
    106106    # can be used as argument for establish_connection, for easy 
    107107    # re-establishing of the connection. 
    108108    def self.remove_connection(klass=self) 
    109       conn = @@defined_connections[klass] 
     109      conn = @@defined_connections[klass]       
    110110      @@defined_connections.delete(klass) 
    111111      active_connections[klass] = nil 
    112112      @connection = nil 
     
    115115 
    116116    # Set the connection for the class. 
    117117    def self.connection=(spec) 
    118       if spec.kind_of?(ActiveRecord::ConnectionAdapters::AbstractAdapter) 
     118      if spec.kind_of?(ActiveRecord::ConnectionAdapters::AbstractAdapter) or spec.kind_of?(ActiveRecord::ConnectionPool::Wrapper) 
    119119        active_connections[self] = spec 
    120120      elsif spec.kind_of?(ConnectionSpecification) 
    121121        self.connection = self.send(spec.adapter_method, spec.config) 
  • activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

    old new  
    4444        @runtime = 0 
    4545        return rt 
    4646      end 
     47       
     48      def close 
     49        begin 
     50          @connection.close 
     51        rescue Exception => e 
     52          log_info("error while closing connection: #{e.message}") 
     53          raise ActiveRecord::ActiveRecordError 
     54        end 
     55      end 
    4756 
    4857      protected   
    4958        def log(sql, name) 
  • activerecord/lib/active_record/base.rb

    old new  
    325325    cattr_accessor :allow_concurrency 
    326326    @@allow_concurrency = true 
    327327     
     328    # Determines whether or not to use a connection pool to manage the actual connections.   
     329    # Is tested and applied on a class by class basis.  When set to true, @@allow_concurrency is  
     330    # effectively disregarded 
     331    cattr_accessor :pool_connections 
     332    @@pool_connections = false 
     333 
     334    cattr_accessor :connection_pool 
     335    @@connection_pool=nil 
     336     
     337    # Initial and minimum size of the connection pool.  Meaningful only when @@pool_connections is true 
     338    cattr_accessor :pool_connections_min 
     339    @@pool_connections_min = 0 
     340 
     341    # Maximum size of the connection pool.  Meaningful only when @@pool_connections is true 
     342    cattr_accessor :pool_connections_max 
     343    @@pool_connections_max = 0 
     344 
     345    # Whether or not a thread will wait for a pool connection to become available,  
     346    # or if ConnectionNotEstablished is thrown 
     347    cattr_accessor :pool_connections_wait 
     348    @@pool_connections_wait = true 
     349    
     350    # Period in seconds between sweeping for unused connections in the pool 
     351    cattr_accessor :pool_connections_reaper_period 
     352    @@pool_connections_reaper_period = 30 
     353 
    328354    # Determines whether to speed up access by generating optimized reader 
    329355    # methods to avoid expensive calls to method_missing when accessing 
    330356    # attributes by name. You might want to set this to false in development 
  • activerecord/lib/active_record.rb

    old new  
    7373  require "active_record/connection_adapters/#{adapter}_adapter" 
    7474end 
    7575 
     76require 'active_record/connection_pool' 
    7677require 'active_record/query_cache'