aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Reap connections based on owning-thread deathMatthew Draper2014-03-181-28/+28
| | | | | | | | | | | | | | | | .. 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.
* Distinguish ConnectionNotEstablished messages: no conn pool for the class, ↵Jeremy Kemper2014-02-221-1/+4
| | | | or no conn available from the pool
* Reaper has access to threadsafe active? callKevin Casey2014-02-081-1/+1
|
* Typos. return -> returns. [ci skip]Lauro Caetano2013-12-031-1/+1
|
* rescue from all exceptions in `ConnectionManagement#call`Vipul A M2013-07-221-1/+1
| | | | | | | | | 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.
* Remove deprecated AR::Connection#clear_stale_cached_connections! methodFrancesco Rodriguez2013-07-011-5/+0
|
* Move method used only in the test to the test code itselfIvan Kataitsev2013-04-251-8/+0
|
* use `connect_poll` on pg so that reaping does not hurt the connectionAaron Patterson2013-03-201-1/+3
|
* Revert "default the reaping frequency to 10 seconds"Aaron Patterson2013-03-201-1/+1
| | | | | | | mysql can't handle a parallel thread pinging the connection, so we can get wrong results or segvs This reverts commit 7cc588b684f6d1af3e7fab1edfa6715e269e41a2.
* default the reaping frequency to 10 secondsAaron Patterson2013-03-111-1/+1
|
* Gist URLs are now namespacedAkira Matsuda2013-02-181-4/+4
| | | | see: https://github.com/blog/1406-namespaced-gists
* Default dead_connection_timeout to 5Akira Matsuda2013-01-241-1/+1
| | | | or the ConnectionPool silently fails to close connections inside the Thread
* fix anonymous class issueDavid2013-01-201-0/+1
|
* These are already required through AS/railsAkira Matsuda2013-01-071-1/+0
| | | | | | * dependencies/autoload * concern * deprecation
* Replace some global Hash usages with the new thread safe cache.thedarkone2012-12-141-9/+16
| | | | | | | | | | | | | | | | 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 7b6bfe84f3 and f345e2380c. * Use TS::Cache in the connection pool to avoid locking overhead. * Use TS::Cache in ConnectionHandler.
* Fix memory leak in development modeJon Leighton2012-11-301-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keying these hashes by klass causes reloadable classes to never get freed. Thanks to @thedarkone for pointing this out in the comments on 221571beb6b4bb7437989bdefaf421f993ab6002. 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
* Properly deprecate ConnectionHandler#connection_poolsJon Leighton2012-11-091-6/+14
| | | | | | | | Rather than just changing it and hoping for the best. Requested by @jeremy: https://github.com/rails/rails/commit/ba1544d71628abff2777c9c514142d7e9a159111#commitcomment-2106059
* Remove ActiveRecord::ModelJon Leighton2012-10-261-4/+4
| | | | | | | | | | 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.
* 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
|