aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/pooled_connections_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-16/+12
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-3/+3
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-4/+4
|
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-1/+1
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Fix connection leak when a thread checks in additional connections.Matt Jones2014-12-231-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | The code in `ConnectionPool#release` assumed that a single thread only ever holds a single connection, and thus that releasing a connection only requires the owning thread_id. There is a trivial counterexample to this assumption: code that checks out additional connections from the pool in the same thread. For instance: connection_1 = ActiveRecord::Base.connection connection_2 = ActiveRecord::Base.connection_pool.checkout ActiveRecord::Base.connection_pool.checkin(connection_2) connection_3 = ActiveRecord::Base.connection At this point, connection_1 has been removed from the `@reserved_connections` hash, causing a NEW connection to be returned as connection_3 and the loss of any tracking info on connection_1. As long as the thread in this example lives, connection_1 will be inaccessible and un-reapable. If this block of code runs more times than the size of the connection pool in a single thread, every subsequent connection attempt will timeout, as all of the available connections have been leaked. Reverts parts of 9e457a8654fa89fe329719f88ae3679aefb21e56 and essentially all of 4367d2f05cbeda855820e25a08353d4b7b3457ac
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Remove dead test code for unsupported adaptersSean Griffin2014-05-171-1/+1
|
* Use teardown helper method.Guo Xiang Tan2014-03-141-1/+1
| | | | | | | | 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.
* remove dead codeAaron Patterson2013-07-081-16/+0
|
* Remove ActiveRecord::ModelJon Leighton2012-10-261-9/+9
| | | | | | | | | | 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.
* ConnectionPool wait_timeout no longer used for different types of timeouts. ↵Jonathan Rochkind2012-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #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.
* Fix CIJon Leighton2011-12-281-9/+9
|
* Removed test which works only < 1.9Arun Agrawal2011-12-211-8/+0
|
* pushing caching and visitors down to the connectionAaron Patterson2011-11-191-72/+0
|
* Transactional fixtures enlist all active database connections.Jeremy Kemper2011-10-051-0/+2
| | | | You can use multiple databases in your tests without disabling transactional fixtures.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* implements ActiveRecord::Base.connection_config to be able to check the ↵Xavier Noria2011-03-051-0/+5
| | | | configuration of the current connection at runtime
* Enable the sqlite3 in-memory test connection to workJon Leighton2011-01-111-1/+1
|
* removing useless ternaryAaron Patterson2010-08-191-1/+1
|
* expected value should come first in assert_equalNeeraj Singh2010-05-181-3/+3
| | | | | | [#4630 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Move AR logging responsibilities to ActiveRecord::Railties::Subscriber.José Valim2010-01-131-12/+1
|
* Expose connections available in the connection pool.José Valim2010-01-111-0/+2
|
* Resolve deadlock in pooled connections testJeremy Kemper2009-11-101-1/+1
|
* Modify connection pool callbacks to be compatible w/ new styleNick Sieger2009-10-161-2/+19
| | | | Signed-off-by: Yehuda Katz <wycats@gmail.com>
* Tests should use ActiveRecord::Base.connection.rollback_db_transaction to ↵steve2009-05-011-1/+1
| | | | | | rollback a transaction Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure ActiveRecord::Base.connection_pool.with_connection creates a new ↵steve2009-05-011-0/+29
| | | | | | connection only when needed [#1752 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fix typo in pool_conections_test [#1350 state:committed]Amos King2008-11-141-1/+1
| | | | Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
* Timeout the connection pool monitor on ruby 1.8 onlyJeremy Kemper2008-11-081-4/+7
|
* Make sure ActiveRecord::Base.connected? doesn't raise an exception for ↵Pratik Naik2008-11-061-0/+5
| | | | defined connections
* Ensure ActiveRecord::ConnectionPool.connected? handles undefined ↵Wes Oldenbeuving2008-11-061-0/+8
| | | | | | connections. [#936 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Make clear_active_connections! also return stale connections back to the poolNick Sieger2008-08-291-0/+87
- also clean up some cruft remaining from per-thread connection cache