Handle database connection within partition strategies
Problem
Partition strategies use Gitlab::Database::PostgresPartition to get the partition details.
These partition info is in-turn used from different places, outside the strategy (eg: models). If a proper connection is not used explicitly then the strategy might result in unexpected results, eg: using the default main database for ci/sec tables. Such cases for tough to debug and have a greater negative impact.
Solution
Always use the proper connection while accessing the partition related module (eg: strategies). If the connection is not specified explicitly, then the partition strategy should fallback to its model's (this is passed while instantiating the strategy) connection.
References
Edited by Allison Browne