Skip to content
This repository

Mar 18, 2014

  1. Matthew Draper

    Reap connections based on owning-thread death

    .. not a general timeout.
    
    Now, if a thread checks out a connection then dies, we can immediately
    recover that connection and re-use it.
    
    This should alleviate the pool exhaustion discussed in #12867. More
    importantly, it entirely avoids the potential issues of the reaper
    attempting to check whether connections are still active: as long as the
    owning thread is alive, the connection is its business alone.
    
    As a no-op reap is now trivial (only entails checking a thread status
    per connection), we can also perform one in-line any time we decide to
    sleep for a connection.
    authored March 08, 2014

Feb 22, 2014

  1. Jeremy Kemper

    Distinguish ConnectionNotEstablished messages: no conn pool for the c…

    …lass, or no conn available from the pool
    authored February 22, 2014

Feb 09, 2014

  1. Kevin Casey

    Reaper has access to threadsafe active? call

    authored February 08, 2014

Dec 03, 2013

  1. Lauro Caetano

    Typos. return -> returns. [ci skip]

    authored December 03, 2013

Jul 22, 2013

  1. Vipul A M

    rescue from all exceptions in `ConnectionManagement#call`

    Fixes #11497
    
    As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does not rescue from Exception (but only from StandardError),
    the Connection Pool quickly runs out of connections when multiple erroneous Requests come in right after each other.
    
    Recueing from all exceptions and not just StandardError, fixes this behaviour.
    authored July 22, 2013

Jul 02, 2013

  1. Francesco Rodríguez

    Remove deprecated AR::Connection#clear_stale_cached_connections! method

    authored July 01, 2013

Apr 24, 2013

  1. Ivan Kataitsev

    Move method used only in the test to the test code itself

    authored April 24, 2013

Mar 20, 2013

  1. Aaron Patterson

    use `connect_poll` on pg so that reaping does not hurt the connection

    authored March 20, 2013
  2. Aaron Patterson

    Revert "default the reaping frequency to 10 seconds"

    mysql can't handle a parallel thread pinging the connection, so we can
    get wrong results or segvs
    
    This reverts commit 7cc588b.
    authored March 20, 2013

Mar 11, 2013

  1. Aaron Patterson

    default the reaping frequency to 10 seconds

    authored March 11, 2013

Feb 18, 2013

  1. Akira Matsuda

    Gist URLs are now namespaced

    authored February 18, 2013

Jan 24, 2013

  1. Akira Matsuda

    Default dead_connection_timeout to 5

    or the ConnectionPool silently fails to close connections inside the Thread
    authored January 24, 2013

Jan 19, 2013

  1. David Wang

    fix anonymous class issue

    authored January 20, 2013

Jan 06, 2013

  1. Akira Matsuda

    These are already required through AS/rails

    * dependencies/autoload
    * concern
    * deprecation
    authored January 06, 2013

Dec 14, 2012

  1. Replace some global Hash usages with the new thread safe cache.

    Summary of the changes:
     * Add thread_safe gem.
     * Use thread safe cache for digestor caching.
     * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation.
     * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache.
     * Use TS::Cache to avoid the synchronisation overhead on listener retrieval.
     * Replace synchronisation with TS::Cache usage.
     * Use a preallocated array for performance/memory reasons.
     * Update the controllers cache to the new AS::Dependencies::ClassCache API.
       The original @controllers cache no longer makes much sense after @tenderlove's
       changes in 7b6bfe8 and f345e23.
     * Use TS::Cache in the connection pool to avoid locking overhead.
     * Use TS::Cache in ConnectionHandler.
    authored December 13, 2012

Nov 30, 2012

  1. Jon Leighton

    Fix memory leak in development mode

    Keying these hashes by klass causes reloadable classes to never get
    freed. Thanks to @thedarkone for pointing this out in
    the comments on 221571b.
    
    This doesn't seem to make a massive difference to performance.
    
    Benchmark
    ---------
    
    require 'active_record'
    require 'benchmark/ips'
    
    class Post < ActiveRecord::Base
      establish_connection adapter: 'sqlite3', database: ':memory:'
    end
    
    GC.disable
    
    Benchmark.ips(20) do |r|
      r.report { Post.connection }
    end
    
    Before
    ------
    
    Calculating -------------------------------------
                              5632 i/100ms
    -------------------------------------------------
                           218671.0 (±1.9%) i/s -    4364800 in  19.969401s
    
    After
    -----
    
    Calculating -------------------------------------
                              8743 i/100ms
    -------------------------------------------------
                           206525.9 (±17.8%) i/s -    4039266 in  19.992590s
    authored November 30, 2012

Nov 09, 2012

  1. Jon Leighton

    Properly deprecate ConnectionHandler#connection_pools

    Rather than just changing it and hoping for the best.
    
    Requested by @jeremy:
    
    ba1544d#commitcomment-2106059
    authored November 09, 2012

Oct 26, 2012

  1. Jon Leighton

    Remove ActiveRecord::Model

    In the end I think the pain of implementing this seamlessly was not
    worth the gain provided.
    
    The intention was that it would allow plain ruby objects that might not
    live in your main application to be subclassed and have persistence
    mixed in. But I've decided that the benefit of doing that is not worth
    the amount of complexity that the implementation introduced.
    authored October 26, 2012

Sep 20, 2012

  1. Francesco Rodríguez

    rename AR::Model::Tag to AR::Tag - fixes #7714

    authored September 20, 2012

Sep 12, 2012

  1. Arun Agrawal

    warning removed.

    1. Unused variable
    2. possibly useless use of a variable in 
    void context
    authored September 12, 2012

Sep 11, 2012

  1. Jonathan Rochkind

    ConnectionPool, unify exceptions, ConnectionTimeoutError

    As a result of different commits, ConnectionPool had become
    of two minds about exceptions, sometimes using PoolFullError
    and sometimes using ConnectionTimeoutError. In fact, it was
    using ConnectionTimeoutError internally, but then recueing
    and re-raising as a PoolFullError.
    
    There's no reason for this bifurcation, standardize on
    ConnectionTimeoutError, which is the rails2 name and still
    accurately describes semantics at this point.
    
    History
    
    In Rails2, ConnectionPool raises a ConnectionTimeoutError if
    it can't get a connection within timeout.
    
    Originally in master/rails3, @tenderlove had planned on removing
    wait/blocking in connectionpool entirely, at that point he changed
    exception to PoolFullError.
    
    But then later wait/blocking came back, but exception remained
    PoolFullError.
    
    Then in 02b2335 pmahoney introduced fair waiting logic, and
    brought back ConnectionTimeoutError, introducing the weird bifurcation.
    
    ConnectionTimeoutError accurately describes semantics as of this
    point, and is backwards compat with rails2, there's no reason
    for PoolFullError to be introduced, and no reason for two
    different exception types to be used internally, no reason
    to rescue one and re-raise as another.  Unify!
    authored September 11, 2012

Sep 05, 2012

  1. Andreas Loupasakis

    Fix a typo

    authored September 06, 2012

Aug 31, 2012

  1. Jon Leighton

    Cache the connection pool for a given class

    authored August 31, 2012
  2. Jon Leighton

    One hash is enough

    We don't need separate @class_to_pool and @connection_pool hashes.
    authored August 31, 2012
  3. Jon Leighton

    Refactor connection handler

    authored August 31, 2012
  4. Jon Leighton

    Make connection pool retrieval faster

    * Loop rather than recurse in retrieve_connection_pool
    * Key the hash by class rather than class name. This avoids creating
      unnecessary strings.
    authored August 31, 2012

Jun 15, 2012

  1. Jon Leighton

    Simplify AR configuration code.

    Get rid of ActiveModel::Configuration, make better use of
    ActiveSupport::Concern + class_attribute, etc.

May 25, 2012

  1. pmahoney

    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.
    authored May 25, 2012

May 23, 2012

  1. Rafael Mendonça França

    Whitespaces :scissors:

  2. Jonathan Rochkind

    ConnectionPool wait_timeout no longer used for different types of tim…

    …eouts. #6441
    
    An AR ConnectionSpec `wait_timeout` is pre-patch used for three
    different things:
    
    * mysql2 uses it for MySQL's own wait_timeout (how long MySQL
      should allow an idle connection before closing it), and
      defaults to 2592000 seconds.
    * ConnectionPool uses it for "number of seconds to block and
      wait for a connection before giving up and raising a timeout error",
      default 5 seconds.
    * ConnectionPool uses it for the Reaper, for deciding if a 'dead'
      connection can be reaped. Default 5 seconds.
    
    Previously, if you want to change these from defaults, you need
    to change them all together. This is problematic _especially_
    for the mysql2/ConnectionPool conflict, you will generally _not_
    want them to be the same, as evidenced by their wildly different
    defaults. This has caused real problems for people #6441 #2894
    
    But as long as we're changing this, forcing renaming the
    ConnectionPool key to be more specific, it made sense
    to seperate the two ConnectionPool uses too -- these two
    types of ConnectionPool timeouts ought to be able to be
    changed independently, you won't neccesarily want them
    to be the same, even though the defaults are (currently)
    the same.
    authored May 23, 2012

May 22, 2012

  1. Rafael Mendonça França

    Revert "Merge pull request #6416 from pmahoney/threadsafe-connection-…

    …pool"
    
    This reverts commit d2901f0, reversing
    changes made to 525839f.
    
    Conflicts:
    	activerecord/test/cases/connection_pool_test.rb
    
    Reason: This change broke the build (http://travis-ci.org/#!/rails/rails/builds/1391490)
    and we don't have any solution until now. I asked the author to try to
    fix it and open a new pull request.

May 21, 2012

  1. pmahoney

    Make connection pool fair with respect to waiting threads.

    authored May 20, 2012

May 19, 2012

  1. pmahoney

    Synchronize read and modification of @reserved_connections hash to av…

    …oid concurrency error.
    authored May 19, 2012

Apr 29, 2012

  1. Mark Rushakoff

    Remove unused assignments

Apr 16, 2012

  1. Aaron Patterson

    opening a connection will block if the pool is full

    authored April 15, 2012
Something went wrong with that request. Please try again.