Commit Graph

37 Commits

Author SHA1 Message Date
Ivan Kataitsev
df0cb9e34c Move method used only in the test to the test code itself 2013-04-25 01:43:28 +04:00
Aaron Patterson
8d3e5c8c52 hide more data in the schema cache 2013-03-14 22:45:46 -07:00
Aaron Patterson
a0dfd84440 safely publish columns and columns hash info 2013-03-14 22:45:46 -07:00
Rafael Mendonça França
5294ad82c6 Alias refute methods to assert_not and perfer assert_not on tests 2012-12-31 13:58:52 -03:00
Jon Leighton
68e4442ec7 Fix memory leak in development mode
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
2012-11-30 11:50:11 +00:00
Carlos Antonio da Silva
daa7b4e2f0 Use "refute" instead of "assert !"
Remove FIXME tag from abstract adapter test.
2012-11-27 21:15:53 -02:00
Jon Leighton
c3ca7ac09e Properly deprecate ConnectionHandler#connection_pools
Rather than just changing it and hoping for the best.

Requested by @jeremy:

ba1544d716 (commitcomment-2106059)
2012-11-09 14:40:15 +00:00
Jon Leighton
9e4c41c903 Remove ActiveRecord::Model
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.
2012-10-26 15:51:02 +01:00
Francesco Rodriguez
a30b8d38b4 rename AR::Model::Tag to AR::Tag - fixes #7714 2012-09-20 12:43:12 -05:00
Jon Leighton
e96558f813 Cache the connection pool for a given class 2012-08-31 15:56:28 +01:00
Jon Leighton
221571beb6 Make connection pool retrieval faster
* Loop rather than recurse in retrieve_connection_pool
* Key the hash by class rather than class name. This avoids creating
  unnecessary strings.
2012-08-31 15:56:27 +01:00
Jon Leighton
e030f26ad3 Simplify AR configuration code.
Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc.
2012-06-15 19:15:36 +01:00
Patrick Mahoney
02b2335563 Make connection pool fair with respect to waiting threads.
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.
2012-05-25 13:19:19 -05:00
Rafael Mendonça França
7c69e2db36 Revert "Merge pull request #6416 from pmahoney/threadsafe-connection-pool"
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.
2012-05-22 15:01:36 -03:00
Patrick Mahoney
d06674d5df Make connection pool fair with respect to waiting threads. 2012-05-20 21:48:04 -05:00
Piotr Sarnacki
ea40990f4b Allow to run connection_adapters/quoting_test.rb independently 2012-05-09 17:08:36 -07:00
Aaron Patterson
df0324f7dd Merge pull request #5362 from zenprogrammer/quoting_bug
Fixed bug in ActiveRecord that caused classes to be quoted incorrectly
2012-05-09 16:12:07 -07:00
Ryan Oblak
12c44fe7f5 Fixed bug in Quoting that caused classes to be quoted incorrectly 2012-03-09 16:33:40 -08:00
kennyj
5ca4fc9581 Add support schema cache dump and load. 2012-03-01 00:52:04 +09:00
Aaron Patterson
ddde548816 connection specification will deep copy the config 2011-12-30 15:35:21 -08:00
Jon Leighton
dae7b65453 Support establishing connection on ActiveRecord::Model.
This is the 'top level' connection, inherited by any models that include
ActiveRecord::Model or inherit from ActiveRecord::Base.
2011-12-28 18:27:41 +00:00
Jon Leighton
7293cac854 Extract common logic into a method 2011-12-24 11:08:15 +00:00
Jon Leighton
7b1eeea5bc Should clear the primary keys cache also 2011-12-16 13:52:07 +00:00
Jon Leighton
7f20bb995a Don't store defaults in the schema cache 2011-12-16 13:52:07 +00:00
Jon Leighton
0b08ff7d92 Cache columns at the model level.
Allows two models to use the same table but have different primary keys.
2011-12-16 13:52:07 +00:00
Aaron Patterson
29d2040b29 AbstractAdapter#close can be called to add the connection back to the
pool.
2011-11-29 14:40:37 -08:00
Aaron Patterson
f866f66b30 expire will set in_use to false 2011-11-29 14:02:58 -08:00
Aaron Patterson
79306de791 last_use is set on connection lease 2011-11-29 14:02:58 -08:00
Aaron Patterson
134cc8f939 Leased connections return false on second lease 2011-11-29 14:02:58 -08:00
Aaron Patterson
9bf8bf82b9 Adapters keep in_use flag when leased 2011-11-29 14:02:58 -08:00
Jon Leighton
1defb6adb8 Fix schema_cache_test.rb for sqlite3_mem 2011-11-29 12:29:42 +00:00
Aaron Patterson
ffb218c750 pools are 1:1 with spec now rather than 1:1 with class 2011-11-28 15:23:25 -08:00
Aaron Patterson
bd2f5c062d pushing caching and visitors down to the connection 2011-11-19 20:19:53 -08:00
Aaron Patterson
4edf6ea0ea Merge pull request #2897 from rsutphin/ar31-remove_connection
Patch for issue #2820
2011-09-06 17:43:58 -07:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the 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. 2011-06-04 23:47:03 +01:00
Aaron Patterson
25f94971ab adding active_connections? to the connection pool for finding open connections 2011-03-28 17:29:37 -07:00