1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/support
eileencodes d9639a211f
Allow async executor to be configurable
This is a followup/alternative to #41406. This change wouldn't work for
GitHub because we intend to implement an executor for each database and
use the database configuration to set the `min_threads` and
`max_threads` for each one.

The changes here borrow from #41406 by implementing an
`Concurrent::ImmediateExecutor` by default. Otherwise applications have
the option of having one global thread pool that is used by all connections
or a thread pool for each connection. A global thread pool can set with
`config.active_record.async_query_executor = :global_thread_pool`. This
will create a single `Concurrent::ThreadPoolExecutor` for applications
to utilize. By default the concurrency is 4, but it can be changed for the
`global_thread_pool` by setting `global_executor_concurrency` to another
number. If applications want to use a thread pool per database
connection they can set `config.active_record.async_query_executor =
:multi_thread_pool`. This will create a `Concurrent::ThreadPoolExecutor`
for each database connection and set the `min_threads` and `max_threads`
by their configuration values or the defaults.

I've also moved the async tests out of the adapter test and into their
own tests and added tests for all the new functionality. This change
would allow us at GitHub to control threads per database and per
writer/reader or other apps to use one global executor. The immediate
executor allows apps to no-op by default.

Took the immediate executor idea from Jean's PR.
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2021-02-19 12:34:57 -05:00
..
marshal_compatibility_fixtures Revert "Merge pull request #39759 from kamipo/marshal_load_legacy_ar_object" 2021-02-18 17:13:41 +09:00
stubs Change safe guard to check for each_pair instead of stringify_keys 2020-02-07 11:36:35 -05:00
yaml_compatibility_fixtures Fix yaml_compatibility_fixtures/rails_v1_mysql.yml's structure 2020-06-30 23:32:05 +09:00
config.rb Extract internal ActiveSupport::ConfigurationFile object 2020-02-10 02:50:12 +01:00
connection.rb Allow async executor to be configurable 2021-02-19 12:34:57 -05:00
connection_helper.rb Deprecate #remove_connection in favor of #remove_connection_pool 2020-01-21 16:49:20 -05:00
ddl_helper.rb
schema_dumping_helper.rb