aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
Commit message (Collapse)AuthorAgeFilesLines
* rename AR::Model::Tag to AR::Tag - fixes #7714Francesco Rodriguez2012-09-201-3/+3
|
* warning removed.Arun Agrawal2012-09-121-1/+0
| | | | | 1. Unused variable 2. possibly useless use of a variable in void context
* ConnectionPool, unify exceptions, ConnectionTimeoutErrorJonathan Rochkind2012-09-111-17/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 02b233556377 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!
* Fix a typoAndreas Loupasakis2012-09-061-1/+1
|
* Cache the connection pool for a given classJon Leighton2012-08-311-20/+35
|
* One hash is enoughJon Leighton2012-08-311-17/+13
| | | | We don't need separate @class_to_pool and @connection_pool hashes.
* Refactor connection handlerJon Leighton2012-08-311-22/+14
|
* Make connection pool retrieval fasterJon Leighton2012-08-311-10/+13
| | | | | | * Loop rather than recurse in retrieve_connection_pool * Key the hash by class rather than class name. This avoids creating unnecessary strings.
* Simplify AR configuration code.Jon Leighton2012-06-151-6/+8
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* Make connection pool fair with respect to waiting threads.Patrick Mahoney2012-05-251-37/+174
| | | | | | | | | | | | | | | 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.
* Whitespaces :scissors:Rafael Mendonça França2012-05-231-6/+6
|
* ConnectionPool wait_timeout no longer used for different types of timeouts. ↵Jonathan Rochkind2012-05-231-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #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.
* Revert "Merge pull request #6416 from pmahoney/threadsafe-connection-pool"Rafael Mendonça França2012-05-221-86/+34
| | | | | | | | | | | | This reverts commit d2901f0fc4270a765717ad572d559dc49a56b3a8, reversing changes made to 525839fdd8cc34d6d524f204528d5b6f36fe410c. 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.
* Make connection pool fair with respect to waiting threads.Patrick Mahoney2012-05-201-34/+86
|
* Synchronize read and modification of @reserved_connections hash to avoid ↵Patrick Mahoney2012-05-191-4/+8
| | | | concurrency error.
* Remove unused assignmentsMark Rushakoff2012-04-291-5/+3
|
* opening a connection will block if the pool is fullAaron Patterson2012-04-151-20/+39
|
* make sure connections returned after close are marked as in_useAaron Patterson2012-03-121-4/+17
|
* deprecated clear_stale_active_connections! can call #reap instead of ↵Jonathan Rochkind2012-03-121-1/+2
| | | | no-op'ing, #reap does the same thing
* make active_connection? return true only if there is an open connection in ↵Aaron Patterson2012-03-081-7/+4
| | | | use for the current thread. fixes #5330
* removes verify_active_connections!Xavier Noria2012-02-241-15/+0
| | | | | | | The method verify_active_connections! was used in the old days (up to 2.1 I think) by the dispatcher to verify the connections, but nowadays we do that in a different way and this method is obsolete.
* use Process.pid rather than $$Aaron Patterson2012-02-161-5/+5
|
* database connections are automatically established after forking.Aaron Patterson2012-02-161-13/+47
| | | | Connection pools are 1:1 with pids.
* use Rack::BodyProxy in activerecord middlewaresSergey Nartimov2012-01-161-31/+5
|
* updating the reaping frequency documentationAaron Patterson2011-12-301-0/+3
|
* rename start to run and use Thread.pass rather than sleeping to schedule the ↵Aaron Patterson2011-12-301-2/+2
| | | | watchdog
* connection pool starts the reaperAaron Patterson2011-12-301-0/+1
|
* each connection pool has a reaperAaron Patterson2011-12-301-1/+5
|
* introduce a timer class for reaping connectionsAaron Patterson2011-12-301-0/+19
|
* raise a pull full error when the connection pool is full and no connection ↵Aaron Patterson2011-12-301-18/+20
| | | | can be obtained
* connections are only removed if they are inactveAaron Patterson2011-12-301-1/+1
|
* connections can be reaped via the `reap` methodAaron Patterson2011-12-301-0/+12
|
* deal with removing connections associated with the current threadAaron Patterson2011-12-301-0/+7
|
* connections can be removed from the poolAaron Patterson2011-12-301-1/+9
|
* queue and signal no longer neededAaron Patterson2011-12-301-2/+0
|
* refactor checking out the connectionAaron Patterson2011-12-301-5/+6
|
* infinite loop is no longer necessaryAaron Patterson2011-12-301-20/+11
|
* connections must be checked in at the end of a threadAaron Patterson2011-12-301-17/+1
|
* Support establishing connection on ActiveRecord::Model.Jon Leighton2011-12-281-1/+1
| | | | | This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base.
* Extract common logic into a methodJon Leighton2011-12-241-6/+1
|
* I herd you like modules.Jon Leighton2011-12-241-1/+6
|
* removing deprecated methodsAaron Patterson2011-12-211-28/+0
|
* push synchronization in to each method. Reduces method calls and makesAaron Patterson2011-11-291-25/+29
| | | | it clear which methods are synchronized.
* Automatic closure of connections in threads is deprecated. For exampleAaron Patterson2011-11-291-1/+7
| | | | | | | | | | | | | | | | | 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.
* AbstractAdapter#close can be called to add the connection back to theAaron Patterson2011-11-291-0/+1
| | | | pool.
* Start implementing @reserved_connections in terms of connection leases.Aaron Patterson2011-11-291-3/+3
|
* Rename `checked_out` to more descriptive `active_connections`Aaron Patterson2011-11-291-3/+3
|
* Use connection lease to determine "checked_out" connectionsAaron Patterson2011-11-291-17/+21
|
* remove unused instance variableAaron Patterson2011-11-281-1/+0
|
* just check in all connectionsAaron Patterson2011-11-281-6/+2
|