I am developing an application that connects to multiple databases. Each request triggers a job designed to connect to a specific database. This job will then execute a series of queries. Currently, the system can handle up to five simultaneous jobs.
The issue arises when a second request is received; the first job then encounters the following error:
No connection pool for 'ActiveRecord::Base' found.
The database connection in each job is established as follows:
<code> ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
encoding: 'utf8mb4',
collation: 'utf8mb4_unicode_ci',
reconnect: true,
pool: 5,
database: db_database,
username: db_username,
password: db_password,
host: db_host
)
</code>
<code> ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
encoding: 'utf8mb4',
collation: 'utf8mb4_unicode_ci',
reconnect: true,
pool: 5,
database: db_database,
username: db_username,
password: db_password,
host: db_host
)
</code>
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
encoding: 'utf8mb4',
collation: 'utf8mb4_unicode_ci',
reconnect: true,
pool: 5,
database: db_database,
username: db_username,
password: db_password,
host: db_host
)
Is there any way to solve this?