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

19 commits

Author SHA1 Message Date
Vladimir Dementyev
6ea356e978
fix activerecord reaper_test 2019-01-02 17:55:48 -05:00
Guo Xiang Tan
d5c1a5b1f5 Improve tests for ActiveRecord::ConnectionAdapters::ConnectionPool configurations. 2018-08-19 23:07:04 +08:00
Daniel Colson
a1ac18671a Replace assert ! with assert_not
This autocorrects the violations after adding a custom cop in
3305c78dcd.
2018-04-19 08:11:33 -04:00
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
Matthew Draper
9027fafff6 Flush idle database connections 2017-11-26 15:12:50 +10:30
Kir Shatrov
831be98f9a Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Xavier Noria
9617db2078 applies new string literal convention in activerecord/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:26:53 +02:00
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