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
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
..
active_record/connection_adapters
activejob Merge pull request #41093 from gwincr11/action-job-transactions 2021-02-01 19:11:26 -05:00
assets
cases Allow async executor to be configurable 2021-02-19 12:34:57 -05:00
fixtures Avoid stack level too deep in predicate builder 2021-02-11 11:32:20 -05:00
migrations Show a warning when running no migration using SCOPE 2021-01-26 15:05:35 +01:00
models Merge pull request #41394 from afrase/recursive-association-fix 2021-02-11 18:32:52 -05:00
schema Merge pull request #41394 from afrase/recursive-association-fix 2021-02-11 18:32:52 -05:00
support Allow async executor to be configurable 2021-02-19 12:34:57 -05:00
config.example.yml Make we always type cast TimeWithZone objects before passing to mysql2 2021-02-11 22:45:14 +00:00
config.rb