1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

10 commits

Author SHA1 Message Date
korbin
27955b4bb1 fix issue with reaping_frequency type
When using DATABASE_URL to configure ActiveRecord, :reaping_frequency
does not get converted from a string to a numeric value. This value is
eventually passed to 'sleep' and must be numeric to avoid exceptions.

This commit converts :reaping_frequency to a float when present.
2014-12-17 19:45:31 -07:00
Matthew Draper
9e457a8654 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.
2014-03-18 10:33:00 +10:30
Guo Xiang Tan
3baace687c Use teardown helper method.
Follow-Up to https://github.com/rails/rails/pull/14348

Ensure that SQLCounter.clear_log is called after each test.

This is a step to prevent side effects when running tests. This will allow us to run them in random order.
2014-03-14 20:48:59 -07:00
Kevin Casey
02a3c0e771 Reaper has access to threadsafe active? call 2014-02-08 17:38:54 -08:00
Jonathan Rochkind
cb6f839359 ConnectionPool wait_timeout no longer used for different types of timeouts. #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.
2012-05-23 12:08:11 -04:00
Aaron Patterson
59f2696d00 rename start to run and use Thread.pass rather than sleeping to schedule the watchdog 2011-12-30 16:10:53 -08:00
Aaron Patterson
405aeb5da4 connection pool starts the reaper 2011-12-30 15:39:39 -08:00
Aaron Patterson
3af68df080 just dup the spec now that it will deep copy 2011-12-30 15:36:48 -08:00
Aaron Patterson
41c24eb3e3 each connection pool has a reaper 2011-12-30 15:27:41 -08:00
Aaron Patterson
cde7692d4e introduce a timer class for reaping connections 2011-12-30 15:19:07 -08:00