Address possible Memoization Bug in Gitlab::Database class
Summary
The Gitlab::Database
class has two methods with different names but they share the same instance variable.
These methods currently have the exact same implementation so this is is not yet an issue. But it could be an issue in the future.
Since the change is trivial, we can fix it easily
Steps to reproduce
- Change the implementation of
database_base_models_using_load_balancing
method (for example, by removing 'ci') so it will return something different thandatabase_base_models_with_gitlab_shared
method - Open Rails console
gdk rails c
- Run
Gitlab::Database.database_base_models_using_load_balancing
- Run
Gitlab::Database.database_base_models_with_gitlab_shared
- Run
What is the current bug behavior?
Expected return value of Gitlab::Database.database_base_models_with_gitlab_shared
:
=> {"main"=>ActiveRecord::Base, "ci"=>Ci::ApplicationRecord(abstract)}
What is the expected correct behavior?
But it returns exactly the same as database_base_models_using_load_balancing
=> {"main"=>ActiveRecord::Base}