Bug #22838
closedDouble-initialization of dynflow in core and foreman-tasks causes race-condition with ActiveRecord database connection
Description
During the initialization process, we ensure the size of the db pool is sufficient for the executors.
However, we run this twice (once from foreman, second from foreman-tasks). What can happen is:
1. the foreman initializes the world, as part of initialization, there are already some tasks being triggered
2. in the meantime, the foreman-tasks initialization runs as well (https://github.com/theforeman/foreman-tasks/blob/7434c95681f56f2295c82d46ad4a9590fb4763ff/lib/foreman_tasks/engine.rb#L149), and part of the initialization is re-connection of the ActiveRecord::Connection https://github.com/Dynflow/dynflow/blob/cc7c854c5d4c7ee5db883d9f8e285c9db573d83b/lib/dynflow/rails/configuration.rb#L93
3. during the short time, between disconnecting and connecting, there can be something in the tasks running, that requires the active record connection
4. it leads to "No connection pool with 'primary' found" error