-
eileencodes authored
In #41549 a user was getting an error that the `pool_config` was `nil` so the `all_connection_pools` method would raise an error. After getting a reproduction application I saw that if the application is misconfigured this can happen. For example, if an application uses `:all` for the writing role but does not set `config.active_record.writing_role = :all` then the `setup_shared_connection_pool` pool method will get a `nil` value for the `writing_pool_config` and set that in `set_pool_config`. I considered fixing this in `setup_shared_connection_pool` directly and raising an error there, but there's a possibility this _can_ happen in an external gem or application code if they're using these private APIs and realistically we never want any code, Rails or otherwise, to be able to set a `nil` pool config in the pools. Note: In the test I made a new connection handler so that we have isolated pools to test against. Otherwise we'll be testing against the existing pools but we don't want to mess those up. Closes #41549
eileencodes authoredIn #41549 a user was getting an error that the `pool_config` was `nil` so the `all_connection_pools` method would raise an error. After getting a reproduction application I saw that if the application is misconfigured this can happen. For example, if an application uses `:all` for the writing role but does not set `config.active_record.writing_role = :all` then the `setup_shared_connection_pool` pool method will get a `nil` value for the `writing_pool_config` and set that in `set_pool_config`. I considered fixing this in `setup_shared_connection_pool` directly and raising an error there, but there's a possibility this _can_ happen in an external gem or application code if they're using these private APIs and realistically we never want any code, Rails or otherwise, to be able to set a `nil` pool config in the pools. Note: In the test I made a new connection handler so that we have isolated pools to test against. Otherwise we'll be testing against the existing pools but we don't want to mess those up. Closes #41549
Loading