Fix `Gitlab::Database::MultiThreadedMigration` calling `Gitlab::Database.create_connection_pool`
From !62092 (closed) we have seen that Gitlab::Database::MultiThreadedMigration
does not work with many databases.
The are two problems:
- It manually gets connection from
ActiveRecord::Base.connection
. This is probably valid, as migrations do.establish_connection
onActiveRecord::Base
, but also the better is to usesuper
in such case. and calls it against a wrong connection (ActiveRecord::Base
). - It calls
Gitlab::Database.main.create_connection_pool
which does not respect connection given for a given migration run
Solutions:
- Remove this altogether, we don't appear to use that
- Can we use
connection_pool
of a current migration instead of creating a new one?
Ref.: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/database/multi_threaded_migration.rb